#Text expander app android code#
In the above code the expandableListDetail object is used to map the group header strings to their respective children using an ArrayList of Strings. HashMap> expandableListDetail = new HashMap>() ĮxpandableListDetail.put("CRICKET TEAMS", cricket) ĮxpandableListDetail.put("FOOTBALL TEAMS", football) ĮxpandableListDetail.put("BASKETBALL TEAMS", basketball) The ExpandableListDataPump class is defined as below: The layout row of the child items is given below : The layout of the group header of each individual list is given below : Note : We cannot use the value wrap_content for the android:layout_height attribute of the ExpandableListView in XML unless the parent’s size is strictly specified The android:indicatorLeft is the left bound for an items indicator. The activity_main.xml layout consists of an ExpandableListView in a RelativeLayout as shown below :
#Text expander app android android#
A CustomExpandableListAdapter which provides the MainActivity with the data from the ExpandableListDataPump class/li> Android ExpandableListView Code.An ExpandableListDataPump which represents a random data in a List and maps the child item data to the respective group headers using a HashMap.
If the group is expanded, the state state_expanded will be set If the group is empty, the state state_empty will be set. setGroupIndicator(Drawable) : An indicator is drawn besides the group representing its state i.e.If the child is the last child for a group, the state state_last will be set setChildIndicator(Drawable) : This is used to show an indicator besides each item representing the current state.Following are some important methods that are used by this class :