获取键盘出现,而无需点击的EditText键盘、EditText

2023-09-06 22:14:18 作者:Warm light。(暖光)

我使用上AlertDialog自定义布局。自定义布局已提起一个EditText里面我是用得到一个电话。当我显示AlertDialog,为了让键盘键入你必须点击提交的EditText的电话号码。有没有办法让键盘自动弹出,当我调出AlertDialog,使用户不必点击提交的EditText拿到键盘。

I am using a custom layout on an AlertDialog. The custom layout has an EditText filed which I am using to get a phone. When I display the AlertDialog, in order to get the keyboard to type in the phone number you have to click on the EditText filed. Is there a way to get the keyboard to automatically pop up when I bring up the AlertDialog so that the user does not have to click on the EditText filed to get the Keyboard.

谢谢,人员Prasanna

Thanks, Prasanna

推荐答案

刚加入这一行,当你显示您的对话框:

Just add this line when you are showing your dialog:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);