android - Default Onclick of child element in expandablelistview? -
this onclick listener child element.
getexpandablelistview().setonchildclicklistener(new expandablelistview.onchildclicklistener() { @override public boolean onchildclick(expandablelistview parent, view v, int groupposition, int childposition, long id) { // todo auto-generated method stub onchild_click(parent,v, groupposition,childposition, id); return true; } }); it working when click on child element. need select first child default(inside oncreate() method). expanding group using this.
getexpandablelistview().expandgroup(0); i tried these things child element not firing onclick event.but when click on child working.
getexpandablelistview().setitemchecked(1, true); and
getexpandablelistview().setselectedchild(0, 0, true);
first of got set expandablelistview choice mode single.. i'll show you:
explistview.setchoicemode(listview.choice_mode_single); explistview.setitemchecked(numberofchildtocheck+numberofgroupthatisopened+1, true); if want work got collapse other groups when 1 opened. next got set backgroud drowable of explistview childs use selector.
here xml file background:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitfadeduration="@android:integer/config_shortanimtime"> <item android:drawable="@drawable/selected_backgroun" android:state_activated="true"/> <item android:drawable="@drawable/simple_background"/> </selector> there layout inflated set view child items. got set
android:background="@drawable/name_of_your_xml_file_with_selector if it's not clear can ask questions , i'll show images gonna this..
thanks.
Comments
Post a Comment