2010-05-28 50 views
20

下面是我如何設置我的選中文本視圖。怎麼沒有出現複選框?我的複選框沒有出現在我的CheckedTextView中

我也添加了這個,但它沒有影響: listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

<CheckedTextView 
android:id="@+id/ctv_checktext" 
android:layout_width="fill_parent" 
android:paddingLeft="2px" 
android:paddingRight="2px" 
android:paddingTop="2px" 
android:layout_height="wrap_content" 
/> 

回答

49

(我回答我的問題,因爲它是Android的API在無證)

這是不夠的:

listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); 

您需要包括了android:對號=「?機器人:ATTR/listChoiceIndicatorMultiple」 否則

<CheckedTextView 
android:id="@+id/ctv_checktext" 
android:layout_width="fill_parent" 
android:paddingLeft="2px" 
android:paddingRight="2px" 
android:paddingTop="2px" 
android:layout_height="wrap_content" 
android:checkMark="?android:attr/listChoiceIndicatorMultiple" 
/> 
+1

我們如何在沒有xml的代碼中做到這一點? – guness 2013-02-18 17:05:14

+2

CheckedEditText文檔定義[相關方法](http://developer.android.com/reference/android/widget/CheckedTextView.html#attr_android:checkMark)。對於這個例子:'checkedEditText.setCheckMarkDrawable(android.R.attr.listChoiceIndicatorMultiple);' – WonderCsabo 2013-07-17 16:57:03

1

你可以有ÿ我們自己的checkbox.xml在可繪製文件夾 那麼你可以把它寫成android:checkMark =「@ drawable/checkbox」

相關問題