KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Each item in my ListView containt an ImageView and a TextView , this will be filled with remote information. I got an URL for the ImageView , therefore I start an AsyncTask which downloads the image and will call setImageBitmap with the downloaded bitmap. This goes very well but when the ListView is created, the getView() is called to often. It calls about 7 times the getView for the first 10 rows (only 7 visible). (So: 0, 1, etc, 10, 0, 1 etc). Then I can just scroll smoothly to the 10th item. But after that, for each new row the listview calls again about 7 times the getView for the first 10 items. (This will cause lag..) But when I remove the setImageBitmap from the AsyncTask , this all won't happen! What could be the problem? Could it be that some layout is to big which will cause another streak of getViews ? Here some code: <ListView android:id="@+id/mylist" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:layout_below="@+id/mydivider" android:divider="@+color/mycolor" android:dividerHeight="2dp" android:fadingEdge="none" android:fastScrollEnabled="true" android:listSelector="@android:color/transparent" android:scrollbars="horizontal" android:scrollingCache="false" android:smoothScrollbar="false" /> The AsyncTask: public static class MyTask extends AsyncTask<String, Integer, Bitmap> { private LruCache<String, Bitmap> mMap; private String mUri; private int mPosition; private ViewHolder mHolder; public MyTask (ViewHolder holder, int position, LruCache<String, Bitmap> map) { mMap = map; mHolder = holder; mPosition = position; } @O
Tags (comma-separated)
Save Edits
Cancel