尝试以下操作会导致错误。如何从自定义alertdialog中检索用户输入的值?我做了一个setText
来测试这种方式是否有效。
这是我的代码:
View categoryDetailView = View.inflate(this, R.layout.customdialoghotspot, null);
final AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setView(categoryDetailView);
b.setTitle("Add Current Location");
b.setPositiveButton("OK",null);
b.setNegativeButton("Cancel",null);
b.show();
答案 0 :(得分:0)
没关系找到答案
View categoryDetailView = View.inflate(this, R.layout.customdialoghotspot, null);
final AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setView(categoryDetailView);
b.setTitle("Add Current Location");
b.setPositiveButton("OK",null);
b.setNegativeButton("Cancel",null);
AlertDialog a= b.show();
EditText editTextMemberName = (EditText)a.findViewById(R.id.txtNewText);
editTextMemberName.setText("test");