问题
Thanks in advance for any help. I have an application that uses several ListViews. I am re-writing for Lollipop release and converting all ListViews into RecyclerViews. 2 out of 3 conversions were seamless, but I have 1 ListView that has several EditTexts per ViewHolder. After I've converted it to a RecyclerView, the 'tab order' or 'focus order' behaves strangely.
Each ViewHolder has 4 EditTexts. If I start editing one, and press the Next button in the keyboard it advances to edit the next EditText down. Now, about 3 ViewHolders fix on the screen before the view has to scroll. Once I hit next through those all EditTexts in 3 ViewHolders, it jumps back up to the beginning to edit, instead of advancing to the 4th ViewHolder.
I'm sure it is related to the RecyclerView's only holding so many ViewHolders in memory, and recycling them, but I can't find where to override the behavior so it advances to the next ViewHolder down. It does bind the 4th ViewHolder before it jumps back to the top, but doesn't advance to it.
Code to create/instantiate:
adapter = new Adapter(this, R.layout.itemlayout, record.getRecords());
recyclerList = ((RecyclerView) findViewById(R.id.recyclerView));
recyclerList.setLayoutManager(new LinearLayoutManager(this));
recyclerList.setAdapter(adapter);
Applicable part of itemview xml::
<LinearLayout
android:id="@+id/LinearLayout9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".275"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/LinearLayout8"
android:layout_width="fill_parent"
android:layout_height="200dp" >
<LinearLayout
android:id="@+id/LinearLayout5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/lblQtyOrd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginBottom="15dp"
android:layout_marginTop="10dp"
android:focusable="false"
android:text="@string/qty_ord"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="@+id/lblPackList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:focusable="false"
android:text="@string/packlist_qty"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="@+id/lblRcvQty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="15dp"
android:focusable="false"
android:text="@string/rcv_qty"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="@+id/lblLabelCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="27dp"
android:focusable="false"
android:text="@string/rcv_labelCount"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/rcvQtyOrd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:focusable="false"
android:text="@string/qty_ord"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/RcvItmPackListQty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="12"
android:hint="@string/packlist_qty"
android:inputType="number|numberDecimal"
android:selectAllOnFocus="true"
android:maxLength="30" />
<EditText
android:id="@+id/RcvItmQty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="12"
android:hint="@string/rcv_qty"
android:selectAllOnFocus="true"
android:inputType="number|numberDecimal" />
<EditText
android:id="@+id/RcvLabelCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="12"
android:hint="@string/rcv_labelCount"
android:inputType="number"
android:selectAllOnFocus="true" />
</LinearLayout>
</LinearLayout>
<EditText
android:id="@+id/rcvItmNote"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="12"
android:hint="@string/rcv_note"
android:inputType="textCapSentences|textAutoCorrect"
android:imeOptions="actionNext"
android:lines="2"
android:maxLines="2" >
</EditText>
</LinearLayout>
Any thoughts are appreciated. Thanks very much.
来源:https://stackoverflow.com/questions/28615330/multiple-edittexts-in-recyclerview-results-in-strange-tab-order