RecyclerView shows previous values entered in an EditText in new rows

后端 未结 2 775
执念已碎
执念已碎 2021-01-21 14:40

I\'m creating an android app, in which I\'m using recyclerView and the row of recyclerView is having editText.

This is my ReadingAdapter<

2条回答
  •  醉梦人生
    2021-01-21 15:39

    RecyclerView reuse views, in fact it only generate the as many as views that is visible on the screen. so it's expected if you can see a value you set for other rows

    The solution would be set all attributes of the view that you are changing to default or whatever the row should present from your data set

    So put addTextChangedListener insode ViewHolder constructor(you can get position by calling getAdapterPosition()) for better performance and set the editText value inside onBindViewHolder method from your data set

提交回复
热议问题