0

私は通常の 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"
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): onInputShownChanged: true

09-16 17:55:08.527: D/InputMethodManager(31721): onInputShownChanged: false

09-16 17:55:09.282: D/InputMethodManager(31721): onInputShownChanged: true

09-16 17:55:09.322: D/InputMethodManager(31721): onInputShownChanged: false

09-16 17:55:09.522: D/InputMethodManager(31721): onInputShownChanged: true

4

2 に答える 2

0

ソフトキーボードを表示します。これで試してみてください。

InputMethodManager inputManager = (InputMethodManager)            
    Context.getSystemService(Context.INPUT_METHOD_SERVICE); 
    inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(),      
    InputMethodManager.HIDE_NOT_ALWAYS);

onEditTextFocusable() を手動で追加して、キーボードを強制的に表示できるようにすることができます。

于 2013-09-16T09:32:26.333 に答える