我已经放了一些EditText
in 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" />
这是带有一些内容的自定义 xmleditText
:
<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" />
实际上当我点击一个EditText
它会打开键盘,失去焦点并立即关闭键盘,因此不可能在其中写入。我还尝试阅读其他问题,提出这个:
recyclerView.setFocusable(true);
recyclerView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
recyclerView.setAdapter(adapter);
但是,在不同的listview
,它不起作用。
我该如何解决这个问题?
谢谢
最后我用这个解决了它:
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
在 RecyclerView 的布局中,我将其添加到清单中:
android:windowSoftInputMode="stateHidden|adjustPan"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)