EditText不会自动启动
在我的应用程序中,我有一个EditText
。我如何使它不会自动启动?喜欢:一旦他们打开活动,它会自动将鼠标设置为EditText
,键盘被打开,因此他们键入...EditText不会自动启动
是否有任何我可以使它打开(键盘显示和用户可以键入),当他们点击它?
好的,所以从你的问题中我发现你的EditText在开始活动时变得焦点。您可以使用以下命令禁用焦点来禁止键盘。
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
的伟大工程..谢谢=) – 2012-08-06 07:02:28
欢迎你,快乐帮助你:) – Lucifer 2012-08-06 07:34:03
路西法的答案必须工作。但是当我遇到同样的问题时,这个解决方案没有用,而有人向我提出这个建议。
添加一个假布局作为您父级布局中的第一个元素,并使其成为可聚焦的。
像这样:
<ParentLayout
.....
......>
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@android:color/transparent"
android:focusable="true"
android:focusableInTouchMode="true" >
</LinearLayout>
......
......
......
</ParentLayout>
这绝对有效,但最好的解决方法是:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
我用Lucifer解决方案,它的工作,感谢Archie =) – 2012-08-06 07:03:15
你试过将焦点设置呢? – sandrstar 2012-08-06 03:37:56
你想要的确切答案是[this] [1]。 [1]:http://*.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup – Dhrupal 2012-08-06 05:59:38