Я пытаюсь добавить динамические переключатели и текст к нему из массива String. Я могу добавить радиобуты с той же длиной массива, что и «приложение», но текст не отображается. Любая идея?Невозможно добавить текст в динамические радиообъекты
private String[] application = {"ABC", "DEF", "GHI", "JKL"};
RadioButton[] rb = null;
radioGroup = (RadioGroup) mLinearView3.findViewById(R.id.myRadioGroup);
rb = new RadioButton[application.length];
for(int m = 0; m < application.length; m++) {
rb[m] = new RadioButton(getApplicationContext());
rb[m].setText(application[m]);
rb[m].setId(m);
radioGroup.addView(rb[m]);
}
mLinearScrollThird.addView(mLinearView3);
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:id="@+id/myRadioGroup"
android:background="#fff"
android:checkedButton="@+id/sound">
</RadioGroup>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
</LinearLayout>
показать макет, в котором RadioGroup лежа –
Благодарность @NikMyers, добавил макет – Christine
возможно вы используете какое-то темный стиль, и текст должен быть белым, так и с белым backgeound вы не можете видеть это? Я не уверен, но просто проверьте это, измените цвет фона или установите цвет для radobutton. –