android - onItemClickListener stops working after changing visibility of item child -
<?xml version="1.0" encoding="utf-8"?> <relativelayout /* not important */> <textview /* not important */ /> <textview /* not important */ /> <relativelayout /* not important */ android:id="@+id/detaillayout" android:visibility="gone"> <textview /* not important */ /> </relativelayout> </relativelayout>
.
private class itemclicklistener implements adapterview.onitemclicklistener { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { relativelayout detaillayout = (relativelayout) view.findviewbyid(r.id.detaillayout); int detaillayoutvisibility = detaillayout.getvisibility(); if(detaillayoutvisibility == view.gone) { detaillayout.setvisibility(view.visible); } else { detaillayout.setvisibility(view.gone); } } }
first when click item, event fires , detaillayout
changes visibility view.visible
, further attempt click results in no event firing.
first things first, create global variable detaillayout
instead of initializing every time click. in oncreate
set click listener of detaillayout
this
since implemented onclicklistener
.
also, why did implement adapterview.onitemclicklistener
instead of view.onclicklistener
? want click relativelayout
not adapter right?
instead of setting visibility of detaillayout
gone
, try same child views of detaillayout
, i.e. set visibility of textview
inside detaillayout
gone
.
Comments
Post a Comment