使用 Android 对话框显示键盘
我想展示带有文本输入的 模型对话框 的 Android 版本,但我认为键盘将位于实际的后面活动,因为对话框没有输入。有什么方法可以让键盘显示在实际的对话框中。
我确实看到了 this SO 问题 - 但是我不想使用 Theme.Dialog'ed 活动,因为我感觉一项活动对于我的目的来说太重了。如何在前台显示带有键盘输入的模型对话框?
这就是我要说的:
I want to show the Android version of a Model Dialog with text input however I think the keyboard will be behind the actual activity since dialogs weren't made to have inputs. Is there any way I can get the keyboard to show in an actual dialog.
I did see this SO question -- however I'd rather not use an Theme.Dialog'ed activity because I feel like an activity would be too heavy for my purposes. How can I show this Model Dialog with the keyboard input in the foreground?
This is what I am talking about:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谁说对话框不能输入?!对话框可以包含任何内容 - 文本、按钮、进度条、输入字段。你尝试过吗?键盘会调整画布的大小,因此不会出现“后面”/“前面”的情况。 (此外,您始终可以在没有 QWERTY 的手机上调用 IME
按住菜单按钮(即使有一个 modAl 对话框)。)
编辑:如果您需要证明,只需查看 API 演示(应用程序 -> 对话框)。有一个带有文本输入的对话框的示例。源代码在这里: http: //developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.html (DIALOG_TEXT_ENTRY)
Who said dialogs aren't made to have inputs?! A dialog can contain anything - text, buttons, progress bars, input fields. Did you try it out? A keyboard resizes your canvas, so there's no "behind"/"front" going on. (Besides, you can always summon the IME on a phone without a QWERTY
keyboard by holding the menu button - even there's a modAl dialog.)
EDIT: If you need proof, just look at the API Demos (App -> Dialog). There's an example for a dialog with text entry. Source code here: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/AlertDialogSamples.html (DIALOG_TEXT_ENTRY)