开发者

SimpleCursorAdapter / ListAdapter with Multiple Sources

Is it possible to build a ListAdapter having elements come from different sources (not 开发者_如何转开发just one cursor).

// Build up a list of names

// Query table1.name

// Query table2.name

// Create a ListAdapter passing in the list of names.

Here's the example for creating a cursor from a single table:

SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor, new String[] { NAME }, new int[] { 
android.R.id.text1 });
setListAdapter(adapter);
adapter.setFilterQueryProvider(m_filterQueryProvider);
if (rememberLastConstraint && m_filterQueryProvider.getConstraint() != null) {
    adapter.getFilter().filter(m_filterQueryProvider.getConstraint());
}


One method would be to compile all the data for the ListView in a data structure outside the ListView adapter and then pass it to the ListView and called notify data set changed. This way you can get data from different type of sources into the ListView.


Yes. To merge cursors use MergeCursor

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜