奇怪:android EditText无法显示软键盘(它会快速隐藏)
我有一个普通的EditText视图,当点击它时,软键盘显示, 但奇怪的问题是它隐藏得很快。布局代码: 就这些奇怪:android EditText无法显示软键盘(它会快速隐藏),android,android-edittext,android-softkeyboard,Android,Android Edittext,Android Softkeyboard,我有一个普通的EditText视图,当点击它时,软键盘显示, 但奇怪的问题是它隐藏得很快。布局代码: 就这些 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/pick_school_bitmap_bg"
>
<LinearLayout
android:id="@+id/customer_action_bar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/bg_action_bar_repeat"
android:orientation="horizontal"
>
<Button
android:id="@+id/home"
android:layout_width="48dp"
android:layout_height="match_parent"
android:background="@drawable/pick_school_item_background"
android:drawableLeft="@drawable/home_as_up_indicator"
android:drawableRight="@drawable/pick_school_ic_menu_search"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp" />
<EditText
android:id="@+id/input_search_school"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/pick_school_textfield_activated"
android:hint="@string/pick_school_search_hint"
android:imeOptions="actionSearch"
android:inputType="text"
android:singleLine="true"
android:textColor="@color/white"
android:textColorHint="@color/white"
/>
</LinearLayout>
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/customer_action_bar"
layout="@layout/pick_school_search_view" />
</RelativeLayout>
太奇怪了,软键盘显示并很快消失:
日志信息为:
09-16 17:55:08.472:D/InputMethodManager(31721):OnInputShowChanged:true
09-16 17:55:08.527:D/InputMethodManager(31721):OnInputShowChanged:false
09-16 17:55:09.282:D/InputMethodManager(31721):OnInputShowChanged:true
09-16 17:55:09.322:D/InputMethodManager(31721):OnInputShowChanged:false
09-16 17:55:09.522:D/InputMethodManager(31721):OnInputShow更改:true以显示软键盘。你能试试这个吗。
InputMethodManager inputManager = (InputMethodManager)
Context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
您还可以手动添加onEditTextFocusable(),强制键盘可访问。尝试在清单文件中添加此行
android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan"
将焦点设置为edittext,以便弹出键盘
<EditText
android:id="@+id/idEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:inputType="textCapCharacters"
android:paddingLeft="20dp"
android:textSize="24sp" >
<requestFocus />
</EditText>
分享您的EditTextLayoutCode立即更新布局代码我尝试了您的布局,但没有包括¸“pick_school_search_view”以及您的颜色和图像。它工作正常键盘在单击视图时出现,并一直保持到按back键。谢谢您的回答,但我尝试了,它不工作。编辑文本获得焦点时,软键会显示,但很快就会消失。注意:我曾尝试在WindowsofInputMode中显示stateVisible,但它没有解决我的问题,它只是在活动开始时显示软键盘。谢谢,我试过了,但这不能解决我的问题。我的问题是软键盘秀,很快就会消失。
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(edittext, 0);