ListView Item is not clickable in Android -
in listview not clickable, want perform action on item click not know why not clickable, have checked in debugging controller not gone in itemclicklistener.
design file :
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <checkbox android:id="@+id/cbsolved" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_marginleft="15dp" android:layout_margintop="20dp" android:text="show solved" /> <checkbox android:id="@+id/cbmycases" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/cbsolved" android:layout_alignbottom="@+id/cbsolved" android:layout_alignparentright="true" android:layout_marginright="46dp" android:text="my cases" /> <edittext android:id="@+id/etcaseseacrh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/cbsolved" android:layout_marginleft="28dp" android:ems="10" android:hint="search" > </edittext> <listview android:id="@+id/licases" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/btnnewcase" android:layout_alignparentleft="true" android:layout_below="@+id/etcaseseacrh" android:layout_margintop="23dp" android:clickable="true" > </listview> <button android:id="@+id/btnnewcase" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:layout_alignparentright="true" android:text="new case" /> </relativelayout>
this java class in accessing list not clickable
public class showcases extends activity{ listview listshowcase; edittext search; listviewadapter adapter; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.screen4); listshowcase = (listview) findviewbyid(r.id.licases); adapter = new listviewadapter(this); listshowcase.setadapter(adapter); listshowcase.setclickable(true); listshowcase.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view view, int arg2, long arg3) { // todo auto-generated method stub string name = ((textview) view.findviewbyid(r.id.name)).gettext().tostring(); string cost = ((textview) view.findviewbyid(r.id.email)).gettext().tostring(); string description = ((textview) view.findviewbyid(r.id.mobile)).gettext().tostring(); string id = ((textview) view.findviewbyid(r.id.id)).gettext().tostring(); // starting new intent intent in = new intent(getapplicationcontext(), companydetail.class); in.putextra("name", name); in.putextra("email", cost); in.putextra("ff", description); in.putextra("fff", id); startactivity(in); } }); search=(edittext)findviewbyid(r.id.etcaseseacrh); search.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { // call adapter current character filter } @override public void beforetextchanged(charsequence s, int start, int count,int after) { } @override public void aftertextchanged(editable arg0) { // todo auto-generated method stub } }); }
and getview of custom listadapter class
@override public view getview(final int paramint, view paramview, final viewgroup paramviewgroup) { // todo auto-generated method stub layoutinflater inflator = activity.getlayoutinflater(); if (paramview == null) { view = new viewholder(); paramview = inflator.inflate(r.layout.list_item, null); view.name = (textview) paramview.findviewbyid(r.id.name); view.email = (textview) paramview.findviewbyid(r.id.email); view.mobile = (textview) paramview.findviewbyid(r.id.mobile); view.id = (textview) paramview.findviewbyid(r.id.id); paramview.settag(view); } else { view = (viewholder) paramview.gettag(); } view.name.settext(tag_name.get(paramint)); view.email.settext(tag_email.get(paramint)); view.mobile.settext(tag_phone_mobile.get(paramint)); view.id.settext(tag_id.get(paramint)); /*view.name.setfocusableintouchmode(false); view.name.setfocusable(false);*/ /*view.setonclicklistener(myclicklistener);*/ view.name.setfocusable(false); view.email.setfocusable(false); view.mobile.setfocusable(false); view.id.setfocusable(false); return paramview; }
ok have button in there. in list_item xml put android:descendantfocusability="blocksdescendants"
in linearlayout or relativelayout have.
Comments
Post a Comment