android - Why are clicks in my ExpandableListView ignored? -
android - Why are clicks in my ExpandableListView ignored? -
i have alertdialog populated expandablelistview. list works perfectly, reason clicks ignored. apparently click handler never called.
this code:
alertdialog.builder builder = new alertdialog.builder(this); builder.settitle("select something"); expandablelistview mylist = new expandablelistview(this); myexpandablelistadapter myadapter = new myexpandablelistadapter(); mylist.setadapter(myadapter); mylist.setonitemclicklistener(new expandablelistview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { seek { toast.maketext(expandablelist1.this, "you clicked me", toast.length_long).show(); } catch(exception e) { system.out.println("something wrong here "); } } }); builder.setview(mylist); dialog = builder.create(); dialog.show(); if instead seek populate alertdialog plain listview, click events generated without problems:
alertdialog.builder builder = new alertdialog.builder(this); builder.settitle("select color mode"); listview modelist = new listview(this); string[] stringarray = new string[] { "bright mode", "normal mode" }; arrayadapter<string> modeadapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1, android.r.id.text1, stringarray); modelist.setadapter(modeadapter); modelist.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { // when clicked, show toast textview text toast.maketext(getapplicationcontext(), ((textview) view).gettext(), toast.length_short).show(); } }); builder.setview(modelist); alertdialog dialog1 = builder.create(); dialog1.show(); what reason why click event fails in expandablelistview not in normal listview? missing something, have no thought be.
ok, solution quite simple. since expandable list, item clicks captured list open kid elements. thus, event handler never called.
instead have implement onchildclicklistener() - name suggests - listens kid clicks!
android expandablelistview
Comments
Post a Comment