Android listview with expandable list view item

痴心易碎 提交于 2019-12-13 16:16:57

问题


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.

thank you!

dejvid


回答1:


You have three options.

  • 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.

    Example of ExpandableListView

  • 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.

    Example of listview

  • If you have a small quantity of items consider using a linearlayout to look like a listview and another linearlayout for the last item.

For example

  <LinearLayout android:orientation="vertical">     

      <TextView />

      <TextView />

      <LinearLayout 
          android:orientation="vertical" 
          android:onClik="expand">

          <TextView />

          <TextView />

      </LinearLayout>

  </LinearLayout>


来源:https://stackoverflow.com/questions/17700251/android-listview-with-expandable-list-view-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!