2011-11-15 83 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"); 
相關問題