android - Adding a button in group indicatior in expandablelistview does not expand list? -
i have app contain expandablelistview default groupindicator , child items. want add toggle button on right side of group header when listview not expand. pls me out porblem.
code:-
@override public view getgroupview(int groupposition, boolean isexpanded, view convertview, viewgroup parent) { whitelistmodel model = whiteliststorage.get(groupposition); if (convertview == null) { layoutinflater infalinflater = (layoutinflater) this._context .getsystemservice(context.layout_inflater_service); convertview = infalinflater.inflate(r.layout.white_list_group_header, null); } textview t = (textview) convertview.findviewbyid(r.id.lbllistheader); t.settypeface(null, typeface.bold); t.settext(model.getname()); return convertview; }
main activity xml:-
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#f4f4f4" > <expandablelistview android:id="@+id/lvexp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:choicemode="singlechoice"/>
group header xml:-
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="12dp"> <textview android:id="@+id/lbllistheader" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingleft="?android:attr/expandablelistpreferreditempaddingleft" android:textcolor="#000" android:textsize="17dp" /> <android.support.v7.widget.switchcompat android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/lbllistheader" android:layout_alignparentright="true" android:layout_marginright="4dp" android:checked="true" />
expand group using expandablelistview.expandgroup(pos) in switchcompat's listener method when switchcompat is checked , call expandablelistview.collapsegroup(pos) when unchecked.
Comments
Post a Comment