Подтвердить что ты не робот

Навигация (далее) с помощью EditText в ListView/RecyclerView

У меня есть EditText внутри RecyclerView (до того, как у меня был ListView, и у меня была та же проблема)

Итак, каждая ячейка, я должен заполнить свой EditText и затем нажать "Далее", чтобы перейти к следующему EditText.

Thing is Next работает для видимых строк. Итак, после 7 строк появляется кнопка "Готово".

Это способ обойти его?

Я пробовал:

android:imeOptions="actionNext"

без результата

В противном случае хорошим способом должно быть прокрутка 1 элемента каждый раз, когда я нажимаю "Далее". Есть ли способ сделать это???

Тх

4b9b3361

Ответ 1

Hey Friend,

First at all, I am telling you the reason why it happening.

As we ALL KNOW that RecyclerView is latest update version as Compare with ListView in Android.

 - **RecycleView**
There ViewHolder Class we have to declare to use RecycleView
& BindHolder is method of RecycleView which is going to Bind the Data as per List of data with postion of ArrayList/List


But Main thing is that..
In Recycleview...   only that portion of data is binded as per your Screen Portion like 10 item at a time...
        when you scroll the recycle view the holder is clean them and fetch new data from list/arraylist with respect postion.


Holder is going to reuse its cell that y ..its calling Re-Cycle-View....means using same cell/row for display the new record.....

try to do debug test....you will understand what i am trying to say..


that a reason ,  when you enter the text in Editext, that portion of YourScreen  data is correct in order..

but when you scroll down the Recycleview ....data will mismatch with blank space...

because.....RecycleView is using its older View/Holder for binding new Incoming data...

if you have still confuse ....Mail me

Zafar Hussain
[email protected]
8080013893 

Ответ 2

Да,

Recycleview является более гибким, так как сравнивать с Listiew и Viewholder использует себя для новых входящих данных... вот почему... Scroll работает в RecycleView.

И FindviewById не всегда вызывает это, отличительные черты Recycleiew с ViewHolder... Вы также можете прочитать это Recycleview на официальном сайте.

ViewHolder повторно использует свою ячейку, поэтому... он будет отражать новые входящие данные

Ответ 3

Я только что исследовал это и не столкнулся с вашей проблемой. Вот мой Котлин:

    class MainActivity : AppCompatActivity() {

    lateinit var adapter: Adapter

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        adapter = Adapter(this)
        list.adapter = adapter
        list.layoutManager = LinearLayoutManager(this)
    }
}

class Adapter(val context: Context): RecyclerView.Adapter<Adapter.ViewHolder>() {
    override fun onCreateViewHolder(p0: ViewGroup, p1: Int): ViewHolder =
        ViewHolder(LayoutInflater.from(context).inflate(R.layout.row, p0, false))

    override fun getItemCount(): Int = 100

    override fun onBindViewHolder(p0: ViewHolder, p1: Int) {}

    class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView)
}

activity_main.xml:

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

<android.support.v7.widget.RecyclerView
        android:layout_width="0dp"
        android:layout_height="0dp" android:layout_marginTop="8dp"
        app:layout_constraintTop_toTopOf="parent" android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"
        android:layout_marginEnd="8dp" app:layout_constraintStart_toStartOf="parent"
        android:layout_marginStart="8dp" android:id="@+id/list"/>

row.xml:

<EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:text="Name"
        android:ems="10"
        android:id="@+id/editText" android:layout_marginTop="8dp"
        app:layout_constraintTop_toTopOf="parent" android:layout_marginStart="8dp"
        app:layout_constraintStart_toStartOf="parent" android:layout_marginEnd="8dp"
        app:layout_constraintEnd_toEndOf="parent" android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toBottomOf="parent"/>