android - Unexplained ListFragment behaviour inside viewpager -


i have came across issue getting me mad. have viewpager several fragments (all of them instances of same class) hold listview. each listview row has view load in task asynchronously. when task finishes sets bitmap imageview. there no point in showing code sure correct. @ beginning started using listfragment simplicity , worked fine. listviews scroll smoothly , async task executed views inside same fragment user scrolls down. realized need customize listview, created own layout , set listfragment android developer docs states (using predefined id listview listfragment can find it) overriding oncreateview(). , here comes strange thing: goes fine when user scrolls , asynctasks finish , sets bitmap viewpager recreates whole views of selected fragment , adjacent 1 causes more asynctask executed , cycle repeats everytime asynctask sets bitmap. causes lot of freezing when user scrolls due massive redraw , asynctask calls. have tried create custom fragment (not inheriting listfragment) listview happens same, viewpager recreates unnecesary views everytime thread sets bitmap row. please can explain me why doesnt happen when use listfragment , happen in other case? how can solve it? in advance.

edit:
found issue. surprisingly in listview xml layout:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <listview         android:id="@id/android:list"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_marginleft="8dp"         android:layout_marginright="8dp"         android:background="@color/white" >     </listview>  </relativelayout> 

if set listview property android:layout_height="wrap_content" instead of match_parent recreates views of adjacent pages , unnecesary everytime bitmap set asynchronously. problem cannot set height wrap_content if listview has few items drawn till bottom ugly. suggestions please?

ok found answer in post android: wrap_content not working listview

it should never used wrap_contentwith listview, otherwise getview()will called many times unnecesary. seriously, should somewhere explained in docs, made me waste lot of time.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -