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 get me"); } }); adap = new MyAdapter(TourList.this,myList);getListVIEw().setAdapter(adap);
我的自定义适配器是
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
和我的tourList.xml文件看起来像
<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" /></...>解决方法 看看 this讨论是否有帮助…… 总结
以上是内存溢出为你收集整理的android – setOnItemClickListener没有响应Custom ListView全部内容,希望文章能够帮你解决android – setOnItemClickListener没有响应Custom ListView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)