使用可见软件键盘进行的活动
我在这里看到了一些类似的问题,但没有找到我真正想要的东西。我需要创建一个简单的活动,用户必须在其中输入一个数字并将其返回到主活动。布局应仅包含屏幕上半部分的编辑文本和屏幕下半部分的软件键盘。当按下键盘上的“完成”键时,活动应该结束。将不胜感激任何有助于解决此问题的链接或代码片段。
I've seen some similar questions here but haven't found what I was really looking for. I need to create a simple activity where the user must enter a number and return it to the main activity. The layout should contain only an edit text on the upper half of the screen and a software keyboard on the lower half of the screen. The activity should finish when the Done key is pressed on the keyboard. Will appreciate any links or code snippets to help resolve this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您使用自定义对话框来执行此操作。
关键是,您想要键盘进行交互,并在按下数字时返回,不是吗?
如果想要一个示例,您可以创建一个对话框活动,如下所示:
然后在创建时设置此内容:
查找视图将如下所示:
并且对话框 XML 必须有一个表:
因此,当您启动对话框时,会出现一个菜单9 个数字(在我的例子中)在按下 1 时会关闭,并关闭对话框(返回到抛出的位置)
我希望它有帮助!
I recommend you use a Custom dialog to do it.
The point is, you want a keyboard to interaction, and return when a number is pressed, aren't you?
If want an example, you can create a Dialog Activity like:
Then set the this content on create:
find views will be something like this:
And the dialog XML must have a table:
So, when you launch the dialog, appear a menu with 9 numbers (in my case) whom dismiss when push 1 of then, and dismiss the dialog (return to the point where was throw)
I hope it help!!