带有可扩展列表视图项的Android listview
我想要一个列表视图菜单,其中包含一些可单击的元素,而最后一个元素必须是可扩展的列表视图项.我的意思是,当我单击最后一个元素时,应该扩大其他职位.
I want to have a listview menu with few clickable elements and the last element must be an expandable list view item. I mean when i click the last element, an additional positions should be expanded.
谢谢!
dejvid
您有三个选择.
-
使用ExpandableListView,其中每个组项都没有子项,最后一个组项将有子项(单击父组时将被展开),周围有许多示例.
Use ExpandableListView where every group-item have no childs-item and the last group-item would have child-items (they would be expanded when the parent group is clicked), there are many examples arround.
当由getView调用时,在最后一个项目上使用listview和inflate视图,由于在函数上收到它,因此您知道何时加载最后一个位置.
Use listview and inflate views on the last item when called by getView, you know when you are loading the last position because you receive it on the function.
如果您的商品数量较少,请考虑使用线性布局看起来像列表视图,最后一个商品则使用另一个线性布局.
If you have a small quantity of items consider using a linearlayout to look like a listview and another linearlayout for the last item.
例如
<LinearLayout android:orientation="vertical">
<TextView />
<TextView />
<LinearLayout
android:orientation="vertical"
android:onClik="expand">
<TextView />
<TextView />
</LinearLayout>
</LinearLayout>