屏幕上的单选按钮中没有文字
there is no text in radio buttons on screen
in this program, I want to show on screen radio buttons with rooms name
buttonList = new RadioButton[roomNames.length];
btGroup = (RadioGroup) findViewById(R.id.roomList);
RadioGroup.LayoutParams rprms;
for(int i = 0; i < roomNames.length; i++)
{
//buttonList[i] = new RadioButton(this);
RadioButton tempBT = new RadioButton(this);
System.out.println("room name number :"+ i + roomNames[i]);
rprms= new RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
//tempBT.setText(roomNames[i].subSequence(0,roomNames[i].length()));
//tempBT.setTextColor(0);
tempBT.setId(i);
buttonList[i] = tempBT;
btGroup.addView(tempBT, rprms);
//buttonList[i].setText(roomNames[i].subSequence(0,roomNames[i].length()));
//buttonList[i].setTextColor(0);
//btGroup.addView(buttonList[i], rprms);
}
for (int f = 0; f < btGroup.getChildCount(); f++) {
((RadioButton) btGroup.getChildAt(f)).setText(roomNames[f].subSequence(0,roomNames[f].length()));
((RadioButton) btGroup.getChildAt(f)).setTextColor(0);
}
//saving the chosen room name
btGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup arg0, int selectedId) {
for(int j = 0; j < buttonList.length; j++)
{
if(btGroup.getCheckedRadioButtonId() == buttonList[j].getId())
{
roomNameSelected = roomNames[j];
}
}
}
});
but when I run this program I see the radio buttons but there is no text inside
而不是
setTextColor(0);
尝试
setTextColor(Color.BLACK);
in this program, I want to show on screen radio buttons with rooms name
buttonList = new RadioButton[roomNames.length];
btGroup = (RadioGroup) findViewById(R.id.roomList);
RadioGroup.LayoutParams rprms;
for(int i = 0; i < roomNames.length; i++)
{
//buttonList[i] = new RadioButton(this);
RadioButton tempBT = new RadioButton(this);
System.out.println("room name number :"+ i + roomNames[i]);
rprms= new RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
//tempBT.setText(roomNames[i].subSequence(0,roomNames[i].length()));
//tempBT.setTextColor(0);
tempBT.setId(i);
buttonList[i] = tempBT;
btGroup.addView(tempBT, rprms);
//buttonList[i].setText(roomNames[i].subSequence(0,roomNames[i].length()));
//buttonList[i].setTextColor(0);
//btGroup.addView(buttonList[i], rprms);
}
for (int f = 0; f < btGroup.getChildCount(); f++) {
((RadioButton) btGroup.getChildAt(f)).setText(roomNames[f].subSequence(0,roomNames[f].length()));
((RadioButton) btGroup.getChildAt(f)).setTextColor(0);
}
//saving the chosen room name
btGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup arg0, int selectedId) {
for(int j = 0; j < buttonList.length; j++)
{
if(btGroup.getCheckedRadioButtonId() == buttonList[j].getId())
{
roomNameSelected = roomNames[j];
}
}
}
});
but when I run this program I see the radio buttons but there is no text inside
而不是
setTextColor(0);
尝试
setTextColor(Color.BLACK);