2011-11-15 59 views
0

尝试以下操作将导致错误。如何检索用户从自定义alertdialog输入的值?我做了一个setText来测试这种方式是否有效。如何从CustomAlertDialog中的文本编辑器中检索文本

这里是我的代码:

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

没关系找到了答案

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"); 
相关问题