首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Java Android -收音机按钮不显示

Java Android -收音机按钮不显示
EN

Stack Overflow用户
提问于 2016-03-27 15:15:23
回答 1查看 527关注 0票数 0

我创建了两个单选按钮:

  • 首先,蓝牙
  • 第二,对于RS232

但我的申请只显示其中一个。

这是我的密码:

代码语言:javascript
运行
复制
final RadioButton Bluetooth = new RadioButton(this);
Bluetooth.setId(TEXT_ID);
alertDialogBuilder.setView(Bluetooth);
Bluetooth.setText("Bluetooth");
Bluetooth.setTextSize(20);

final RadioButton RS232 = new RadioButton(this);
RS232.setId(TEXT_ID);
alertDialogBuilder.setView(RS232);
RS232.setText("RS232");
RS232.setTextSize(20);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-27 15:54:43

使用此代码定义警报对话框。Creatre是一个xml布局,包含两个单选按钮,然后在java视图中,在警告对话框中包含这个视图。

代码语言:javascript
运行
复制
                View view2 = View.inflate(MyActivity.this, R.layout.radiobutton, null);

                AlertDialog.Builder builderconversion = new AlertDialog.Builder(MyActivity.this);
                //builder1.setMessage("Radio Message");
                builderconversion.setView(view2);
                builderconversion.setCancelable(true);
                builderconversion.setPositiveButton("CLOSE",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {

                                //Methods and functions
                                dialog.cancel();
                            }
                        });

                AlertDialog alertconversion = builderconversion.create();
                alertconversion.show();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36248967

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档