androidcheckboxcheckedtextview

android: CheckedTextView cannot be checked?


Initially I wanted a checkmark where the text is placed on the left of the checkmark. After searching on this site I found out the best workaround is android:CheckedTextView? However, I found out that the checkmark cannot be changed manually by users. Is it by design?

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" 
 android:id="@+id/autoupdatecheckboxview" 
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content" 
 android:gravity="center_vertical" 
 android:checkMark="?android:attr/listChoiceIndicatorMultiple" 
 android:paddingLeft="6dip" 
 android:paddingRight="6dip" 
 android:text="Pop up a message when new data available" 
 android:typeface="sans" android:textSize="16dip"/> 

Solution

  • You probably want to just use a regular CheckBox (which inherits from Button and thus TextView). CheckedTextView is designed to work with list views. Example CheckBox layout XML is below:

    <CheckBox
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Pop up a message when new data available"
        android:textSize="16dip" />