android一个对话框问题请教

玉麟龙 2011-05-23 02:42:09
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))
),如何获取这个文本框的值呢?

...全文
121 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ch_984326013 2011-05-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 easycoola 的回复:]
。。。匿名的怎么获取?因该正常声明一个EditText et = new EditText(self);然后在setview(et);
这样就可以通过et获取值了
[/Quote]
顶....
changy 2011-05-23
  • 打赏
  • 举报
回复
setView之前保存一下就可以了嘛
mahaiyun18 2011-05-23
  • 打赏
  • 举报
回复
我搜了一下这样可已取值:第3行,第9行

01 LayoutInflater factory = LayoutInflater.from(this);

02 final View textEntryView = factory.inflate(R.layout.alert_dialog_userbookmark_entry, null);

03 et=(EditText)textEntryView.findViewById(R.id.bookmark_title);

04 new AlertDialog.Builder(this)

05 .setTitle(R.string.add_bookmark_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_userbookmark(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();
easycoola 2011-05-23
  • 打赏
  • 举报
回复
。。。匿名的怎么获取?因该正常声明一个EditText et = new EditText(self);然后在setview(et);
这样就可以通过et获取值了

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧