android: CheckedTextView cannot be checked?

后端 未结 7 1107
遇见更好的自我
遇见更好的自我 2020-12-08 06:41

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

7条回答
  •  暖寄归人
    2020-12-08 07:10

    Here is my use in SingleChoiceDialog

    1.select_dialog_singlechoice.xml

    
    
    

    2.style.xml

    
    

    3.radio.xml

    
        
        
        
        
        
    
    

    4.In Adapter's getView

    CheckedTextView title = (CheckedTextView) convertView
                    .findViewById(android.R.id.text1);
            title.setText(mItems[position]);
            title.setSelected(mCheckedItem == position ? true : false);
                        title.setCheckMarkDrawable(position == mCheckedItem ?                   R.drawable.dot_selected
                    : R.drawable.dot_normal);
    

提交回复
热议问题