我需要你的帮助来获取刷新时的字符串值,并将其显示在 AlertDialog 中。我想在复制按钮上将文本复制到新字符串
并想在 AlertDialog 中添加“COPY”按钮
String plain ="hello;" // changing on refresh
new AlertDialog.Builder(Demo.this)
.setTitle("New Message")
.setMessage(plain)
.setPositiveButton(android.R.string.ok, null)
.setCancelable(false)
.create().show();
最佳答案
如果您想从警报对话框中发送消息,请尝试以下代码
TextView tv = (TextView)YOUR_ALERT_DIALOG.findViewById(android.R.id.message);
Log.e(this.getClass().getName(), ""+tv.getText());
如果您的警报对话框中未设置消息,它将抛出空指针异常。
关于android - 如何从 Android 中的 AlertDialog 获取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28812906/