2009-11-03 78 views
2

我在layout.xml文件中的以下內容:當我打電話,我onClickListener()在使用CheckedTextView需要幫助的android

<CheckedTextView 
    android:id="@+id/checktext" 
    android:layout_width="fill_parent" 
    android:layout_height="?android:attr/listPreferredItemHeight" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:gravity="center_vertical" 
    android:checkMark="?android:attr/listChoiceIndicatorSingle" 
    android:paddingLeft="6dip" 
    android:paddingRight="6dip" 
/> 

它顯示「單選按鈕」,但?

CheckedTextView numberView2 = (CheckedTextView) v.findViewById(R.id.checktext); 
numberView2.setSelected(true); 
v.invalidate(); 

它沒有顯示'單選按鈕'被選中。我已經通過源代碼步進,它執行'numberView2.setSelected(true);',但它仍然沒有顯示單選按鈕被選中。

你能告訴我爲什麼?我該如何解決我的問題。

+0

你爲什麼使整個父視圖無效而不僅僅是'numberView2'? – 2009-11-03 20:48:02

+0

我不知道。我正在嘗試所有我能想到的方法來實現它。 – hap497 2009-11-03 22:23:33

回答

1

你確定你不想setChecked而不是setSelected?