سؤال

How to add two base adapters to listView in android? I need two adapters, one is for showing phonebook contact and another is for showing application registered contact, i was trying to use Merge adapter, but its not working properly, can anyone help me to solve this issue.

هل كانت مفيدة؟

المحلول

hmm, this should be easy.

1) You can create one adapter with updateData method inside, and then just call it from your activity and then adapter.notifyDataSetChanged();.

For example: Put this in your adapter:

public void updateData(ArrayList<Object> newData)
{
 this.data = newData;
}

Then, in your activity you call this:

  myAdapter.updateData(data);
  myAdapter.notifyDataSetChanged();

2) Create two adapters with different data.

To set the adapter just call:

listView.setAdapter(adapter1);

And second one:

listView.setAdapter(adapter2);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top