这是我的自定义适配器:
...
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(android.R.layout.simple_list_item_checked, parent, false);
return v;
}
...
现在,从视觉上看来这正是我所需要的。问题是单击列表视图项时无法切换选中状态。有什么办法吗?
最佳答案
我很快发现这样做的草率方法:
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
CheckedTextView textview = (CheckedTextView)v;
textview.setChecked(!textview.isChecked());
}