1
我想用LinearLayout项目(它将包含CheckedTextView和多个textview)实现listview。
所以我想在ListView中使用LinearLayout而不是CheckedTextView。 我试过了,但单选按钮状态没有改变。
我的代码:如何在Android Listview中使用LinearLayout代替CheckedTextView
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
getListView().setItemsCanFocus(false);
setListAdapter(new ArrayAdapter(this,R.layout.list_item,android.R.id.text1,COUNTRIES));
LIST_ITEM
<CheckedTextView
.....
/>
我想这样
list_item_new
<LinearLayout>
.....
<CheckedTextView/>
<TextView/>
.....
</LinearLayout>
我不明白这是如何解决问题的。问题是LinearLayout中的CheckedTextView在按下时不会改变状态? – 2012-05-23 05:27:15
@GlennBech你试过这个吗?我有 - 并且按需要工作。 – 2012-05-23 08:01:40
我试图使用一个带CursorAdapter膨胀的嵌套checkedTextView的LinearLayout。这不起作用,这就是为什么我最终在这个页面上。为什么应该使用自定义适配器?问题的根源在于LinearLayout没有实现Checkable接口? (http://developer.android.com/reference/android/widget/Checkable.html) – 2012-05-23 09:21:32