Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hasStableIds () in Expandable ListView?

I am creating app Using ExpandableListView ,I referred some tutorials .The hasStableIds () set to false? what is the exact need for making hasStableIds() to false?

like image 828
Asthme Avatar asked Jun 24 '14 11:06

Asthme


People also ask

How do you use expandable list view?

Android ExpandableListView is a view that shows items in a vertically scrolling two-level list. It differs from a ListView by allowing two levels which are groups that can be easily expanded and collapsed by touching to view and their respective children items.

How do I change the icon on expandable list view?

How do I change the icon on expandable list view? Post the listView row xml. @RajeshCP see update one. Onclick of the onItemClick function you can change the source of the group_indicator for that you need a uparrow button or else you can rotate the bitmap by some dregree and set it as a source for that ImageView.

How do you get a child position in ExpandableListView?

You have to use Adapter's getChild(groupPosition, childPosition) method to retrieve the instance of child.


1 Answers

Documentation of hasStableIds()

Indicates whether the child and group IDs are stable across changes to the underlying data.

Returns whether or not the same ID always refers to the same object

It's used when you change the data of the Adapter, everytime you change the data the ExpandableListView should update it's views to reflect the changes.

If true the ExpandableListView can reuse the same View if the ID is the same.

If false it should recreate all the views since it can't have any idea what changes.

The ID which i refer is the ID returned by getGroupId and getItemId.

You should override this methods too!

Some questions:

  • BaseAdapter: set hasStableIds() to false?
  • Android - what is the meaning of StableIDs?
like image 126
Marco Acierno Avatar answered Oct 04 '22 19:10

Marco Acierno