11、打开页面EditText自动获取焦点,如何使系统键盘不自动弹出

方法一:

mainfest文件中把对应的activity设置

android:windowSoftInputMode="stateHidden" 或者android:windowSoftInputMode="stateUnchanged"

或(已测有效)

<activity
    android:name=".view.WorkInfoActivity"
    android:windowSoftInputMode="adjustPan"/>

方法二:

可以在布局中放一个隐藏的TextView,然后在onCreate的时候requsetFocus

注意TextView不要设置Visiable=gone,否则会失效

 <TextView

android:id="@+id/text_notuse"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:focusable="true"

android:focusableInTouchMode="true"

        />

 

TextView textView =(TextView)findViewById(R.id.text_notuse);

            textView.requestFocus();



猜你喜欢

转载自blog.csdn.net/lanxuan1993/article/details/80354266