android - setOnItemClickListener not responding for Custom ListView -
i wrote custom adapter listview ,but when tried implement click event list item ,i found not responding ,i glad if suggest me solution.
public class tourlist extends listactivity { .... setcontentview(r.layout.tourlist); ..... getlistview().setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view,int position, long id) { //i couldn't reach here log.v(tag,"did u me"); } }); adap = new myadapter(tourlist.this,mylist); getlistview().setadapter(adap);
and custom adapter is
private class myadapter extends baseadapter { arraylist<hashmap<string,string>> elements; context ctx; public myadapter(context context, arraylist<hashmap<string,string>> mylist) { this.elements=mylist; this.ctx=context; } public boolean isenabled(int position){ return true; } @override public int getcount() { return elements.size(); } @override public object getitem(int position) { return elements.get(position); } @override public long getitemid(int position) { return position; } @override public view getview(int position, view convertview, viewgroup parent) { view v = convertview; if (convertview == null) { layoutinflater vi = (layoutinflater)getsystemservice(context.layout_inflater_service); v = vi.inflate(r.layout.rowfor_tourlist, null); } textview in = (textview)v.findviewbyid(r.id.intro); textview du = (textview)v.findviewbyid(r.id.duration); textview pf = (textview)v.findviewbyid(r.id.price); textview pn = (textview)v.findviewbyid(r.id.product); webview wv=(webview)v.findviewbyid(r.id.photo); in.settext(html.fromhtml(mylist.get(position).get("intro"))); du.settext(mylist.get(position).get("duration")); pf.settext(mylist.get(position).get("price")); pn.settext(mylist.get(position).get("product")); wv.getsettings().setjavascriptenabled(true); wv.loadurl(mylist.get(position).get("imageurl")); return v; } }//class
and tourlist.xml file looks like
<linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" .... > <listview android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/white" android:cachecolorhint="#00000000" android:layout_weight="1" /> </...>
see if this discussion helps...
Comments
Post a Comment