我希望在我的应用中有一个可扩展/可折叠的列表视图,类似于市场中每个应用的评论显示方式(实际上,列表中的每个项目都是与市场中相同格式的评论)。由于可能有很多列表项,我不希望用户丢失列表下方的按钮,并且用户可能没有兴趣阅读列表中的项目,我希望此列表可扩展和可折叠。
我已经看过扩展BaseExpandableListAdapter并且看起来很整洁,除了看起来列表总是使用ExpandableListActivity显示的事实。我想在用户已经查看的页面中嵌入列表。
有没有人知道使用BaseExpandableListAdapter是否可行,或者我是否必须完全使用其他技术并自己编写所有样板代码?
非常感谢, 尼娜
答案 0 :(得分:0)
不确定。应该没问题。 ExpandableListActivity只是ExpandableListView
上的精简贴面(实际上,任何布局都有ExpandableListView
且ID为android.R.id.list
。您可以使用自己的ExpandableListActivity
自定义布局或者定义自己的活动并放弃ExpandableListActivity
提供的(相对较少的)便利方法。
答案 1 :(得分:0)
是的,使用ListView
,ExpandableListView
和没有相关活动的朋友并不困难。
您只需在实例化setAdapter()
或从布局中检索ExpandableListView
后调用ExpandableListView list = (ExpandableListView) findViewById(R.id.listView);
list.setAdapter(myExpandableAdapter);
:
{{1}}