简体   繁体   中英

How to make an ExpandableListView in Android always show child items

I want to make an ExpandableListView which should always be showing its children elements even after clicking the header, and it should not collapse. How could I implement this concept?

you can expand all groups one by one as below as mentioned in this post

ExpandableListView explst;

explst.expandGroup(0);
explst.expandGroup(1);

for disabling collapse you can define a OnGroupClickListener which returns true, like so: (as mentioned in this post)

explst.setOnGroupClickListener(new OnGroupClickListener() {
  @Override
  public boolean onGroupClick(ExpandableListView parent, View v,
                              int groupPosition, long id) { 
    return true; // This way the expander cannot be collapsed
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM