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