RadioButton.setText()未显示文本

赛达·祖奈拉(Syeda Zunaira)

我正在创建RadioButtons并将其动态添加到RadioGroup。但是,当我运行该应用程序时,RadioButton的文本未显示在屏幕上。

这是我的RadioButtons代码

else if ((items.get(i).toString()).equals("rad")) {
                RadioGroup bg = new RadioGroup(getApplicationContext());
                int child=0;
                for (int h = textlen; h < text.size(); textlen++) {

                    if (text.get(textlen).contains("(")) {

                        s = text.get(textlen).replace("(", "");

                        if (s.contains(")"))
                            s = s.replace(")", "");

                    } else if (text.get(textlen).contains(")")) {
                        s = text.get(textlen).replace(")", "");
                    } else
                        s = text.get(textlen);

                    RadioButton radioButton = new RadioButton(
                            getApplicationContext());
                    bg.addView(radioButton);
                    // / radioButton.setName("rbt");
                    if (s.contains("{on}")) {
                    //  radioButton.setSelected(true);
                        radioButton.setChecked(true);
                        s = s.replace("{on}", "");
                    } else {
                        radioButton.setChecked(false);
                        s = s.replace("{of}", "");
                    }
                    //((RadioButton)bg.getChildAt(child)).setText(s);
                    //child++;

                    radioButton.setText(s);

                    String c = text.get(textlen).substring(
                            text.get(textlen).length() - 1);
                    if (c.equals(")")) {
                        textlen++;
                        break;
                    }



                }

                layout.addView(bg);
            }

当我调试代码时,我可以看到该文本已添加到RadioGropus子级中

但是在运行应用程序时,文本不可见。任何人都可以检测到该问题。多谢

用户名

只需添加

setLayoutParams(params);

用于RadioButton以及RadioGroup。

在哪里

android.widget.LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Tkinter Python RadioButton 未选择

来自分类Dev

RadioButton控件下的文本换行

来自分类Dev

从javascript设置asp:RadioButton文本

来自分类Dev

在RadioButton中使用图像代替文本

来自分类Dev

选择RadioButton不会更改面板显示

来自分类Dev

使用jsPDF无法正确显示Radiobutton

来自分类Dev

在RadioButton的底部显示文字,并在Android中显示图片

来自分类Dev

页面加载时根据 RadioButton 选择或值显示文本框

来自分类Dev

Android RadioButton 仅显示文本,而不是设备模拟器中的实际按钮

来自分类Dev

Angular2:RadioButton更改事件未绑定

来自分类Dev

重新启用RadioButton后未触发检查的VisualState

来自分类Dev

RadioButton 未选中 RadioGroup 按钮单击 Xamarin.Android

来自分类Dev

如何保持RadioButton文本和其他Label对齐?

来自分类Dev

以编程方式实现RadioButton的不同文本大小

来自分类Dev

自定义RadioButton框架,内部带有文本

来自分类Dev

tkinter Radiobutton:如何使多行文本与按钮对齐?

来自分类Dev

Primeng p-radioButton-文本作为锚点

来自分类Dev

在面板内的面板内时,RadioButton不显示

来自分类Dev

Vue:如何根据RadioButton的选择显示不同的图像

来自分类Dev

检查项目时,RadioButton不显示项目符号

来自分类Dev

默认情况下,显示选中的RadioButton的内容

来自分类Dev

AlertDialog 显示从 RadioButton 选择的结果,让用户再次检查

来自分类Dev

asp.net RadioButton 对于 selenium 总是显示 false

来自分类Dev

在RadioGroup中选择RadioButton并从Backstack重新创建Fragment时,不会更新android RadioButton文本

来自分类Dev

Edittext setText 未显示任何文本,但记录 getText().toString 显示首先设置的文本

来自分类Dev

RadioButton定制

来自分类Dev

设置带有自定义Shape的RadioGroup中选中的彩色文本RadioButton

来自分类Dev

Android RadioButton阿拉伯语(左侧文本)以编程方式

来自分类Dev

在TextView字段中键入内容时如何更新RadioButton的文本

Related 相关文章

  1. 1

    Tkinter Python RadioButton 未选择

  2. 2

    RadioButton控件下的文本换行

  3. 3

    从javascript设置asp:RadioButton文本

  4. 4

    在RadioButton中使用图像代替文本

  5. 5

    选择RadioButton不会更改面板显示

  6. 6

    使用jsPDF无法正确显示Radiobutton

  7. 7

    在RadioButton的底部显示文字,并在Android中显示图片

  8. 8

    页面加载时根据 RadioButton 选择或值显示文本框

  9. 9

    Android RadioButton 仅显示文本,而不是设备模拟器中的实际按钮

  10. 10

    Angular2:RadioButton更改事件未绑定

  11. 11

    重新启用RadioButton后未触发检查的VisualState

  12. 12

    RadioButton 未选中 RadioGroup 按钮单击 Xamarin.Android

  13. 13

    如何保持RadioButton文本和其他Label对齐?

  14. 14

    以编程方式实现RadioButton的不同文本大小

  15. 15

    自定义RadioButton框架,内部带有文本

  16. 16

    tkinter Radiobutton:如何使多行文本与按钮对齐?

  17. 17

    Primeng p-radioButton-文本作为锚点

  18. 18

    在面板内的面板内时,RadioButton不显示

  19. 19

    Vue:如何根据RadioButton的选择显示不同的图像

  20. 20

    检查项目时,RadioButton不显示项目符号

  21. 21

    默认情况下,显示选中的RadioButton的内容

  22. 22

    AlertDialog 显示从 RadioButton 选择的结果,让用户再次检查

  23. 23

    asp.net RadioButton 对于 selenium 总是显示 false

  24. 24

    在RadioGroup中选择RadioButton并从Backstack重新创建Fragment时,不会更新android RadioButton文本

  25. 25

    Edittext setText 未显示任何文本,但记录 getText().toString 显示首先设置的文本

  26. 26

    RadioButton定制

  27. 27

    设置带有自定义Shape的RadioGroup中选中的彩色文本RadioButton

  28. 28

    Android RadioButton阿拉伯语(左侧文本)以编程方式

  29. 29

    在TextView字段中键入内容时如何更新RadioButton的文本

热门标签

归档