gpt4 book ai didi

java - 屏幕上的单选按钮中没有文字

转载 作者:行者123 更新时间:2023-11-30 10:16:37 25 4
gpt4 key购买 nike

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);

关于java - 屏幕上的单选按钮中没有文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49986955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com