我在我的应用程序中有三个屏幕,并且每个屏幕都有3个editTexts。 我的问题是,当这些活动启动时,默认光标将会跳到第一个edittext并弹出键盘。EditText在android的焦点
我想要的是,当用户点击编辑框,那么只有键盘应该弹出。
由于事先
Sudheer
我在我的应用程序中有三个屏幕,并且每个屏幕都有3个editTexts。 我的问题是,当这些活动启动时,默认光标将会跳到第一个edittext并弹出键盘。EditText在android的焦点
我想要的是,当用户点击编辑框,那么只有键盘应该弹出。
由于事先
Sudheer
在你layout.xml,删除此行(在你的EditText的底部):
<requestFocus />
在XML文件中首先测试的是你可能会在您的编辑文本<requestFocus />
中删除此行,以下是一些可帮助您的示例 Example link
<EditText
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<-- remove this line /// <requestFocus />
</EditText>
也在你的活动添加此
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
谢谢,它的工作 – user1746619 2013-03-19 07:48:27
最好的解决办法是:(manifest文件)
<activity android:name=".MainActivity"
android:windowSoftInputMode="stateHidden" />
试试这个,添加windowSoftInputMode
在中的所有活动就会避免键盘弹出up。当你触摸EditText
那个时候才会出现
android:windowSoftInputMode="stateHidden|adjustPan"
将这个代码在你onCreate()方法。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
参见:http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup – Tushar 2013-03-19 07:12:13
请检查由图沙·指出堆栈溢出问题。 – Midhere 2013-03-19 07:31:27