使用 Android 对话框显示键盘

发布于 2024-09-11 10:28:14 字数 434 浏览 9 评论 0原文

我想展示带有文本输入的 模型对话框 的 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:
alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迟月 2024-09-18 10:28:14

谁说对话框不能输入?!对话框可以包含任何内容 - 文本、按钮、进度条、输入字段。你尝试过吗?键盘会调整画布的大小,因此不会出现“后面”/“前面”的情况。 (此外,您始终可以在没有 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文