new AlertDialog.Builder(self) 
 .setTitle("请输入") 
 .setIcon(android.R.drawable.ic_dialog_info) 
 .setView(new EditText(self)) 
 .setPositiveButton("确定", null) 
 .setNegativeButton("取消", null) 
 .show(); //上面是一个含有输入框的对话框(setView(new EditText(self)) 
),如何获取这个文本框的值呢?

解决方案 »

  1.   

    匿名的怎么获取?因该正常声明一个EditText et = new EditText(self);然后在setview(et);
    这样就可以通过et获取值了
      

  2.   

    我搜了一下这样可已取值:第3行,第9行01 LayoutInflater factory = LayoutInflater.from(this);  02 final View textEntryView = factory.inflate(R.layout.alert_dialog_userbook_entry, null);  03 et=(EditText)textEntryView.findViewById(R.id.book_title);  04 new AlertDialog.Builder(this)  05 .setTitle(R.string.add_book_txt)  06 .setView(textEntryView)  07 .setPositiveButton(R.string.ok_txt, new DialogInterface.OnClickListener() {  08 public void onClick(DialogInterface dialog, int whichButton) {   09 String title=et.getText().toString();  10 if(dbm.insert_userbook(book_id, chapter_id, title, scroll.getScrollY()))  11 alert(getString(R.string.add_success_txt));  12 else 13 alert(getString(R.string.add_fail_txt));  14 }  15 })  16 .setNegativeButton(R.string.cancel_txt, new DialogInterface.OnClickListener() {  17 public void onClick(DialogInterface dialog, int whichButton) {  18    19 /* User clicked cancel so do some stuff */ 20 }  21 })  22 .create().show(); 
      

  3.   

    setView之前保存一下就可以了嘛