如何解决将静态数据添加到使用ListAdapter的动态创建的ListView中
|| 我想将X数量的静态行添加到使用ListAdapter / BaseAdapter来动态填充当前ListView的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);
解决方法
答案是@commonsware的MergeAdapter。有关详细信息,请参见https://github.com/commonsguy/cwac-merge,但对于异构数据源而言,却非常方便。您可以按任意顺序很好地将多个适配器和视图缝合在一起。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。