Android-手动膨胀的listview行上的自定义键盘不显示

Android-手动膨胀的listview行上的自定义键盘不显示,android,listview,android-listview,keyboard,Android,Listview,Android Listview,Keyboard,你好 我有一个android应用程序。在我的应用程序中,我有一个自定义的listView,其中有5列是TextView。用户可以单击行,一旦单击,行布局将更改,将最后2个文本视图更改为EditText。然后,我将新的EditText注册到我的自定义键盘上——请注意,我做了一个关于自定义键盘类以及如何使其在主布局中工作的示例的功能复制粘贴。但是,当我单击行中的编辑文本时,我的自定义键盘根本不显示 我有一个全局变量: CustomKeyboard mCustomKeyboard; 在活动中的onC

你好

我有一个android应用程序。在我的应用程序中,我有一个自定义的listView,其中有5列是TextView。用户可以单击行,一旦单击,行布局将更改,将最后2个文本视图更改为EditText。然后,我将新的EditText注册到我的自定义键盘上——请注意,我做了一个关于自定义键盘类以及如何使其在主布局中工作的示例的功能复制粘贴。但是,当我单击行中的编辑文本时,我的自定义键盘根本不显示

我有一个全局变量:

CustomKeyboard mCustomKeyboard;
在活动中的
onCreate()
方法中,我执行以下操作:

mCustomKeyboard= new CustomKeyboard(this, R.id.keyboardview, R.xml.custom_keyboard);
这是我的布局,布局底部有键盘视图:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".SearchResult" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <!-- A lot of views go here, enclosed in my linear layout -->

    </LinearLayout>

    <android.inputmethodservice.KeyboardView
        android:id="@+id/keyboardview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:visibility="gone" />
</RelativeLayout>
这是我的
搜索结果\u inflate.xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/search_result_inflate"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:minHeight="50dp"
    android:orientation="horizontal"
    android:padding="1dip"
    android:weightSum="1" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal"
        android:padding="1dip" >

        <TextView
            android:id="@+id/dialogItemName"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginRight="2dp"
            android:layout_weight="0.54"
            android:gravity="center"
            android:text="Item Name"
            android:textSize="23sp" />

        <TextView
            android:id="@+id/price"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginRight="2dp"
            android:layout_weight="0.14"
            android:gravity="center"
            android:text="Price"
            android:textSize="23sp" />

        <TextView
            android:id="@+id/discount"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginRight="2dp"
            android:layout_weight="0.10"
            android:gravity="center"
            android:text="Discount"
            android:textSize="23sp" />

        <EditText
            android:id="@+id/qtyInputSearchResult"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginRight="2dp"
            android:layout_weight="0.14"
            android:background="@layout/edittext_selector"
            android:gravity="center"
            android:hint="qtyInput"
            android:textColorHighlight="@color/white_opaque"
            android:textSize="23sp" >
        </EditText>

        <EditText
            android:id="@+id/discInputSearchResult"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.11"
            android:background="@layout/edittext_selector"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center"
            android:hint="discInput"
            android:textColorHighlight="@color/white_opaque"
            android:textSize="23sp" />
    </LinearLayout>

</LinearLayout>

如您所见,我有两个EditText,并且我已向自定义键盘类注册了
qtyInputSearchResult
。但是,自定义键盘不会显示

我还尝试在另一个活动中对editText使用自定义键盘类,效果很好。我是不是遗漏了什么?我不明白为什么自定义键盘不能正确显示


非常感谢您的帮助。

明白了,我将键盘布局放置在search\u result\u inflate.xml中,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/search_result_inflate"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:minHeight="50dp"
    android:orientation="horizontal"
    android:padding="1dip"
    android:weightSum="1" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal"
        android:padding="1dip" >

        <!-- a lot of components here -->

    </LinearLayout>

    <android.inputmethodservice.KeyboardView
        android:id="@+id/keyboardview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:visibility="gone" />

</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/search_result_inflate"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:minHeight="50dp"
    android:orientation="horizontal"
    android:padding="1dip"
    android:weightSum="1" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal"
        android:padding="1dip" >

        <!-- a lot of components here -->

    </LinearLayout>

    <android.inputmethodservice.KeyboardView
        android:id="@+id/keyboardview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:visibility="gone" />

</RelativeLayout>