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