KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm setting a custom SimpleCursorAdapter to a ListView. For some reason FriendAdapter's getView() is called twice for every item in the DB. After some investigation (I have no wrap_content in my contact_list.xml), I can still not figure out why. What could be the reasons? Anybody can help? Thanks ContactSelection.java public class ContactSelection extends ListActivity { private WhipemDBAdapter mDbHelper; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new WhipemDBAdapter(this); mDbHelper.open(); setContentView(R.layout.contact_list); Cursor c = mDbHelper.fetchAllFriends(); startManagingCursor(c); String[] from = new String[] {}; int[] to = new int[] {}; setListAdapter(new FriendAdapter(this, R.layout.contact_row, c, from, to)); getListView().setItemsCanFocus(false); getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); } @Override protected void onResume() { super.onResume(); mDbHelper.open(); } @Override protected void onPause() { super.onPause(); mDbHelper.close(); } } FriendAdapter.java public class FriendAdapter extends SimpleCursorAdapter implements OnClickListener { private Context mContext; private int mLayout; private Cursor mCursor; private int mNameIndex; private int mIdIndex; private LayoutInflater mLayoutInflater; private final ImageDownloader imageDownloader = new ImageDownloader(); private final class ViewHolder { public TextView name; public ImageView image; public CheckBox checkBox; } public FriendAdapter(Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); this.mContext = context;
Tags (comma-separated)
Save Edits
Cancel