关闭软键盘Android中,直到的EditText选择键盘、Android、EditText

2023-09-05 05:18:25 作者:伱長得好似晴天……霹雳

我怎么能prevent软键盘消失,直到一个特定的EditText是choosen?我有几个EditTexts在我的布局,当它开了第一家被自动选中,软键盘显示。

how can I prevent the software keyboard to disappear until a specific EditText is choosen? I have several EditTexts in my Layout when it is opened the first is automatically selected and the software keyboard is shown.

我知道我可以通过设置的android禁用此:作为焦点=假。但后来就不可能按一下该项目并获得显示的项目。

I know i can disable this by setting android:focusable="false". But then it is impossible to click on the item and get the item displayed.

我想:该活动已启动,用户可以看到所有EditTexts,那么他点击一个和软件键盘打开之类的东西可以在EditText上输入。这可能吗?

What I want: The activity is started and the user sees all EditTexts, then he clicks on one and the software keyboard opens and stuff can be entered in the EditText. Is this possible?

推荐答案

在你的活动的onCreate()

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