I am created dynamic checkbox with the following code:
xml:
<LinearLayout
android:id="@+id/layout_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
.java:
LinearLayout ll = (LinearLayout) findViewById(R.id.layout_checkbox);
ll.removeAllViews();
for (int i = 0; i < 10; i++) {
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
AppCompatCheckBox myCheckBox = new AppCompatCheckBox(getApplicationContext());
myCheckBox.setText(i);
myCheckBox.setTextColor(Color.parseColor("#FFFFFF"));
myCheckBox.setHintTextColor(Color.parseColor("#FFFFFF"));
myCheckBox.setTextSize(12);
myCheckBox.setId(i);
ll.addView(myCheckBox, lp);
}
Now from above code only LOLLIPOP
version shows the checkbox with text. And for below LOLLIPOP
version it shows only Text
but not showing the checkbox.
Same thing work with all device if i will put the below code in xml file:
<android.support.v7.widget.AppCompatCheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Testing"
android:buttonTint="@color/colorAccent"/>
But i cant defined the checkbox in xml as i have to created it dynamically.
Even setButtonTintList
is not working for below LOLLIPOP
How can i show the Checkbox for below LOLLIPOP
version with AppCompatCheckBox
?
Aucun commentaire:
Enregistrer un commentaire