Android listview with expandable list view item

10,727

You have three options.

  • Use ExpandableListView where every group-item has no child-item and the last group-item would have child-items (they would be expanded when the parent group is clicked), there are many examples around.

    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 number 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>
Share:
10,727
dejvid
Author by

dejvid

Updated on June 04, 2022

Comments

  • dejvid
    dejvid almost 2 years

    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 position should be expanded.