android - Onclicklistener for a child view inside a ListView item only fired second time after onitemclicklistener -
this situation: have listview items. inside each item there 2 clickable views shown after user clickes in parent item.
it works this:
productlist.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(final adapterview<?> parent, final view view, final int position, long id) { textview txtadd = (textview) view.findviewbyid(r.id.txt_add_units); txtadd.setvisibility(view.visible); txtadd.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { ... } }); textview txtremove = (textview) view.findviewbyid(r.id.txt_remove_units); txtremove.setvisibility(view.visible); txtremove.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { ... } }); basketproductslistadapter.notifydatasetchanged(); } });
the first time listview item clicked, txtadd , txtremove child views shown , if user clicks them, code inside onclicklistener executed.
the problem appears in first listview item. first time clicked txtadd , txtremove shown, first time user clicks on child views, parent's itemclicklistener fired again, , child views (txtadd , txtremove) not receiving clicklistener. following times work perfectly.the weird thing happens first time on first item in listview.
any ideas? in advance!
add line listview xml android:descendantfocusability="blocksdescendants"
the thing our child view may focusable first click focus , after itemclick work. avoide focusable add line in xml
still if not work try adding
android:focusable="false" android:focusableintouchmode="false"
to child view of listview
Comments
Post a Comment