在ListView / RecyclerView中使用EditText导航(下一个)



我有EditText在RecyclerView(之前我有ListView,我有同样的问题)

所以每个单元格,我必须填充我的EditText,然后点击Next进入下一个EditText。

Thing is Next正在为可见行工作。所以在7行之后,按钮Done出现了。

这是一种绕过它的方法吗?

I tried with:

android:imeOptions="actionNext"

没有结果

否则,一个好方法应该是每次单击Next时滚动1个元素。有什么办法可以做到吗?

Tx

Hey Friend,
First at all, I am telling you the reason why it's 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's 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
zafarhussain910@gmail.com
8080013893 

我只是调查了一下,没有遇到你的问题。这是我的Kotlin:

    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"/>

是,

Recycleview是更灵活的比较列表和Viewholder是使用自己的新传入数据…这就是为什么……滚动在RecycleView中正常工作

和FindviewById不是所有的时间调用,与ViewHolder的recycleview的功能…你也可以在官方网站上阅读这个回收视图。

ViewHolder is重用了它的Cell thatsa, reason…它将反映新的传入数据

最新更新