我在复选框的帮助下创建了具有多个选择的自定义列表。最后,我设法在列表的项目选择事件上设置了复选框。在android中定制列表视图
但是当我的复选框没有按照列表的选择被选中时 当我点击第一行第4行的复选框时会自动点击。总之序列不被维护。 与我工作的代码如下
ListAdapter adapter = new SimpleAdapter(
this,
Datalist ,
R.layout.customlist,
new String[] {"fileName","contentLength","keyPath"},
new int[] {R.id.title,R.id.size, R.id.path}
);
setListAdapter(adapter);
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
ViewGroup group=(ViewGroup)v;
CheckBox check=(CheckBox)group.findViewById(R.id.sharecheckbox);
check.toggle();
}
http://stackoverflow.com/questions/7738527/getting-an-issue-while-checking-the-dynamically-generated-checkbox-through-list/7739006#7739006 – MKJParekh
检查本教程在这里给定定制列表的很好例子。 [http://www.vogella.de/articles/AndroidListView/article.html](http://www.vogella.de/articles/AndroidListView/article.html) – Pratik