RecyclerView问题:EditText失去焦点

ste*_*206 9 android android-recyclerview

我已经放了一些EditText,RecyclerView因为我需要得到一些价值.实施是这样的:

<android.support.v7.widget.RecyclerView
    android:layout_below="@id/firstrow"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusableInTouchMode="true"
    android:descendantFocusability="beforeDescendants"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:id="@+id/rectable"
    android:layout_marginLeft="@dimen/table_margin"
    android:layout_marginRight="@dimen/table_margin"
    android:layout_marginBottom="300dp" />
Run Code Online (Sandbox Code Playgroud)

这是自定义xml与一些editText:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/white"
android:orientation="horizontal"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="60dp ">


<TextView
    android:text="TextView"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:id="@+id/description"
    android:layout_weight="1"
    android:textColor="@color/black" />

<View
    style="@style/VerticalSeparator" />


<EditText
    android:hint="lol"
    android:id="@+id/weight"
    android:focusable="true"
    style="@style/DefaultEditCellStyle" />

<View
    style="@style/VerticalSeparator" />

<EditText
    android:hint="lol"
    android:id="@+id/arm"
    android:focusable="true"
    style="@style/DefaultEditCellStyle" />

<View
    style="@style/VerticalSeparator" />


<EditText
    android:hint="lol"
    android:focusable="true"
    android:id="@+id/moment"
    style="@style/DefaultEditCellStyle" />
Run Code Online (Sandbox Code Playgroud)

实际上,当我点击EditText它打开键盘,失去焦点并立即关闭键盘,所以不可能写入这些.我也试过读其他问题,把这个:

recyclerView.setFocusable(true);
        recyclerView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        recyclerView.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

但是,在不同的情况下listview,它不起作用.

我怎么能解决这个问题?谢谢

ste*_*206 9

最后我用这个解决了它:

 android:focusableInTouchMode="true"
 android:descendantFocusability="beforeDescendants"
Run Code Online (Sandbox Code Playgroud)

在RecyclerView的布局中,我将它添加到Manifest中:

android:windowSoftInputMode="stateHidden|adjustPan"
Run Code Online (Sandbox Code Playgroud)