My Checkbox inside xml layout:
<CheckBox
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" />
Inside onCreate() method of the related activity:
CheckBox cb1 = (CheckBox) findViewById(R.id.cb1);
cb1.setSelected(true);
This doesn't show a selected state when I run the app instead checkbox appears unselected. Can't figure out how to solve this issue. Also i need to show the checkbox on the right side and so I am using the property android:drawableRight. I have tried with using custom drawable xml file too, but I am still stuck with the same problem. Please help.
Aucun commentaire:
Enregistrer un commentaire