android - My listitem is not getting clicked -



android - My listitem is not getting clicked -

i have declared setonitemclick listener in show category dataloaded method. there toast not getting fired if item clicked in list.this dataloaded method called in receivertask class list populated server data

#activity class# private arraylist <categorymodel>categorylist; //private static final string[]paths = {"all", "favourites"}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(com.bioscope.r.layout.categorylist); save=(button)findviewbyid(r.id.save); recievecategoriestask task = new recievecategoriestask(this,"all"); task.execute(); save.setvisibility(view.visible); } public void showcateogrydataloaded(arraylist<categorymodel> categorylist) { this.categorylist = categorylist; for(categorymodel c:categorylist) { log.v("title", c.gettitle()); } categoryslistadapter adapter=new categoryslistadapter(this, categorylist); list=(listview) findviewbyid(com.bioscope.r.id.listview1); list.setadapter(adapter); >>list.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { // todo auto-generated method stub toast.maketext(categoryselectonactivity.this, "you clicked item ", toast.length_short).show(); system.out.print("done"); //showeventinformaion(position); checkbox cb = (checkbox) findviewbyid(r.id.select_checkbox); if(cb.ischecked()) cb.setchecked(false); else cb.setchecked(true); } }); }

in listview have set clickable true

#categorylist xml# <?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:layout_margin="0dp" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="0dp" android:orientation="vertical" android:padding="0dp" > <tablelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <tablerow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"> </tablerow> </tablelayout> <view android:layout_width="fill_parent" android:layout_height="3dp" android:background="#c0c0c0"/> <listview android:id="@+id/listview1" android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true" > </listview> </linearlayout> <relativelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="bottom" > <button android:layout_width="fill_parent" android:id="@+id/save" android:visibility="invisible" android:layout_height="wrap_content" android:text="save" android:background="#0099cc" /> </relativelayout> </relativelayout> categorylistitem <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="100dp" > <imageview android:id="@+id/category_icon" android:layout_width="80dp" android:layout_height="80dp" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:src="@drawable/ic_launcher" /> <textview android:id="@+id/category_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_torightof="@+id/category_icon" android:textsize="28sp" android:textcolor="#ffcccccc" android:text="category title" /> <textview android:id="@+id/category_description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_torightof="@+id/category_icon" android:layout_below="@+id/category_title" android:textsize="14sp" android:textcolor="#ffcccccc" android:text="cateogry description" /> <checkbox android:id="@+id/select_checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/category_title" android:layout_alignbottom="@+id/category_title" android:layout_alignparentright="true" android:background="#ffcccccc" android:text="" android:focusable="false" android:focusableintouchmode="false" /> </relativelayout> receivertask progressdialog dialog; string responsestring; categoryselectonactivity appcontext; createeventactivity createeventactivity_appcontext; string url; string pageurl = "get-event-category"; private string useridparameter="user_id="; // string name,email,pass,phone; public recievecategoriestask(categoryselectonactivity c, string critiria) { appcontext = c; // url = utility.baseurl + pageurl + critiria; // url = utility.baseurl + pageurl; url = "http://bioscopebd.com/mobileappand/getusercategory?"+useridparameter+"259214143443955553"; log.i("url", url); } public recievecategoriestask(createeventactivity createeventactivity, string critiria) { createeventactivity_appcontext = createeventactivity; // url = utility.baseurl + pageurl + critiria; // url = utility.baseurl + pageurl; url = "http://bioscopebd.com/mobileappand/getusercategory?"+useridparameter+"259214143443955553"; } protected void onpreexecute() { dialog = new progressdialog(appcontext==null?createeventactivity_appcontext:appcontext); dialog.setprogressstyle(progressdialog.style_spinner); dialog.setmessage("loading categories..."); dialog.show(); super.onpreexecute(); } string filterresponsestring(string r) { homecoming r.replace("\r\n", ""); } @override protected string doinbackground(string... uri) { httpclient httpclient = new defaulthttpclient(); httpresponse response; seek { response = httpclient.execute(new httpget(url)); statusline statusline = response.getstatusline(); if (statusline.getstatuscode() == httpstatus.sc_ok) { bytearrayoutputstream out = new bytearrayoutputstream(); response.getentity().writeto(out); out.close(); responsestring = out.tostring(); responsestring = filterresponsestring(responsestring); } else { // closes connection. response.getentity().getcontent().close(); utility.showmessage(appcontext, "cannot connect internet"); } } grab (exception e) { // todo handle problems.. } homecoming responsestring; } @override protected void onpostexecute(string result) { dialog.dismiss(); if (responsestring != null) { arraylist<categorymodel> categorylist = new arraylist<categorymodel>(); ; jsonarray jsonarr; seek { log.v("json", responsestring); jsonarr = new jsonarray(responsestring); // jsonarr = events.getjsonarray("events"); (int = 0; < jsonarr.length(); i++) { jsonobject jsonobj = jsonarr.getjsonobject(i); categorymodel category = new categorymodel(); category.setid(jsonobj.getstring("event_cat_id")); category.settitle(jsonobj.getstring("event_cat_title")); category.setdescription(jsonobj.getstring("event_cat_desc")); category.setstatus(jsonobj.getboolean("status")); // event.setlogo(jsonobj.getstring("logo").getbytes(charset.forname("utf-8"))); /* * event.setstartdate(jsonobj.getstring("startdate")); * event.setenddate(jsonobj.getstring("enddate")); * * event.setstarttime(jsonobj.getstring("starttime")); * event.setendtime(jsonobj.getstring("endtime")); * event.setcountry(jsonobj.getstring("country")); * event.setcity(jsonobj.getstring("city")); * event.setaddress(jsonobj.getstring("address")); * event.setlogo(jsonobj.getstring("logo")); * event.setbanner(jsonobj.getstring("banner")); * event.setphone(jsonobj.getstring("phone")); * event.setemail(jsonobj.getstring("email")); * * event.setweblink(jsonobj.getstring("weblink")); * event.setpublishdate(jsonobj.getstring("publishdate")); * event.setcategoryid(jsonobj.getstring("categoryid")); */ categorylist.add(category); } } grab (jsonexception e) { // todo auto-generated grab block e.printstacktrace(); } if (appcontext != null) { appcontext.showcateogrydataloaded(categorylist);

// categoryselectonactivity c=new categoryselectonactivity(); // c.visiblesavebutton();

} // appcontext.showcategorylistdataloaded(responsestring); if(createeventactivity_appcontext!=null){ createeventactivity_appcontext.showcateogrydataloaded(categorylist); } } super.onpostexecute(result); // response.. }

what missing??

are getting error (force close)?

see code :

checkbox cb = (checkbox) findviewbyid(r.id.select_checkbox);

change :

checkbox cb = (checkbox) view.findviewbyid(r.id.select_checkbox);

because dont see have checkbox in activitiy's layout, checkbox should in list item. hence, should utilize view onitemclick's param when using findviewbyid

update

try add together android:focusable="false" , android:focusableintouchmode="false" checkbox item.

android

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -