Checkbox setselected does not work when using the Android: drawableright property

My check box is in the XML layout:

<Check@R_379_2419@
                        android:id="@+id/cb1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:layout_marginTop="15dp"
                        android:button="@null"
                        android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
                        android:paddingLeft="6dp"
                        android:paddingRight="5dp"
                        android:text="Trending Stores"
                        android:textColor="@color/black"
                        android:textSize="18sp" />

Within the oncreate() method of the related activity:

Check@R_379_2419@ cb1 = (Check@R_379_2419@) findViewById(R.id.cb1);
cb1.setSelected(true);

When I run the application without displaying the unselected check box, the selected status is not displayed. I can't figure out how to solve this problem. In addition, I need to display the check box on the right, so I use the property Android: drawableright. I have also tried to use a custom drawable XML file, but I still encounter the same problem. Please help

resolvent:

Ah, usually we don't use setselected as Check@R_ 379_ 2419@.

I think you should use setchecked unless you know exactly what you want to do with setselected

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>