android: CheckedTextView cannot be checked?

后端 未结 7 1106
遇见更好的自我
遇见更好的自我 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:11

    simple answer is to add your own onClickListener, and use : isChecked() method instead of isSelected().

    CheckedTextView chkBox = (CheckedTextView) findViewById(R.id.CheckedTextView01);
    chkBox.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v)
        {
            if(((CheckedTextView) v).isChecked()){
                ((CheckedTextView) v).setChecked(false);
            }else{
                ((CheckedTextView) v).setChecked(true);            
            }
        }
    });
    

    and get the status using view.isChecked() method.

    0 讨论(0)
提交回复
热议问题