Activity 启动时显示软键盘

Show soft keyboard when Activity starts(Activity 启动时显示软键盘)
本文介绍了Activity 启动时显示软键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有 2 个活动,A 和 B.当 A 启动时,它会检查一个条件,如果为真,它会调用 startActivityForResult() 来启动 B.B 只接受文本输入,所以这是有意义的B启动时软键盘自动弹出.当活动开始时,EditText 已经有了焦点并准备好输入.

I have 2 activities, A and B. When A starts, it checks for a condition and if true, it calls startActivityForResult() to start B. B only takes text input so it makes sense for the soft keyboard to automatically pop up when B start. When the activity starts, the EditText already has focus and it ready for input.

问题是键盘永远不会出现,即使在清单中为 B 的 <activity> 标记下设置了 windowSoftInputMode="stateAlwaysVisible".我也尝试将值设置为 stateVisible.由于它不会自动显示,我必须点击 EditText 以使其显示.

The problem is that the keyboard never shows up, even with windowSoftInputMode="stateAlwaysVisible" set in the manifest under the <activity> tag for B. I also tried with the value set to stateVisible. Since it doesn't show up automatically, I have to tap the EditText to make it show.

有人知道解决办法是什么吗?

Anyone know what the solution might be?

推荐答案

最适合我的是在 Android Manifest 中添加活动 B

What worked best for me is in Android Manifest for activity B adding

android:windowSoftInputMode="stateVisible"

希望对你也有帮助.

这篇关于Activity 启动时显示软键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum(Android 发布 APK 因 java.lang.AssertionError 崩溃:在 java.lang.Enum 中不可能)
Finished with Non Zero Exit Value 3(以非零退出值 3 结束)
On gradle:3.0.0 More than one file was found with OS independent path #39;META-INF/ASL2.0#39;(在 gradle:3.0.0 上找到多个文件,其独立于操作系统的路径为“META-INF/ASL2.0)
Android : app loading library at runtime on Lollipop but not IceCreamSandwich(Android:运行时在 Lollipop 上而不是 IceCreamSandwich 上的应用程序加载库)
buildConfigField depending on flavor + buildType(buildConfigField 取决于风味 + buildType)
How do I suppress warnings when compiling an android library with gradle?(使用 gradle 编译 android 库时如何抑制警告?)