我想将X数量的静态行添加到ListView,该ListView使用ListAdapter / BaseAdapter来动态填充ListView。有什么建议?
先谢谢,科尔。
我的解决方案:根据@ Femi的建议,我最终使用了MergeAdapter。这是我所做的一小部分:
// create a new MergeAdapter
MergeAdapter aMergeAdapter = new MergeAdapter();
// add the dynamic content
SkipToListActivityValueAdapter skipToListActivityValueAdapter =
new SkipToListActivityValueAdapter(this, sections);
aMergeAdapter.addAdapter(skipToListActivityValueAdapter);
// add the static content
ArrayAdapter<String> aArrayAdapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, ADDITIONAL_SKIP_TO_OPTIONS);
aMergeAdapter.addAdapter(aArrayAdapter);
// add the aMergeAdapter to the ListAdapter
setListAdapter(aMergeAdapter);
答案 0 :(得分:1)
答案是@commonsware的MergeAdapter。有关详细信息,请参阅https://github.com/commonsguy/cwac-merge,但异构数据源的代码非常方便。您可以按照您想要的顺序将多个适配器和视图拼接在一起。