恩,差不多就这些了,由于代码直接写到项目中了,就不写demo了,直接贴一下主要代码,仅供参考,如果您有更好的方法可以相互交流
1,设置 checkbox无法响应点击事件
android:clickable="false" android:focusable="false" android:focusableInTouchMode="false"
private static HashMap<Integer,Boolean> isSelected;
public static HashMap<Integer,Boolean> getIsSelected() { return isSelected; } public static void setIsSelected(HashMap<Integer,Boolean> isSelected) { MyDocShowAdapter.isSelected = isSelected; }
isSelected = new HashMap<Integer, Boolean>(); for(int i=0; i<list.size();i++) { getIsSelected().put(i,false); }
mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ViewHolder holder = (ViewHolder) view.getTag(); holder.mCheckBox.toggle(); MyDocShowAdapter.getIsSelected().put(position, holder.mCheckBox.isChecked()); } });
原文地址:http://blog.csdn.net/elinavampire/article/details/42869015