I have a RecyclerView with an EditText. When I try to add some value to the EditText and slide down and check the EditText value, the value disappears.
Asked
Active
Viewed 273 times
0
-
Possible duplicate of [Saving EditText content in RecyclerView](https://stackoverflow.com/questions/31844373/saving-edittext-content-in-recyclerview) – Ravee Sunshine Aug 26 '17 at 06:16
2 Answers
0
As the name suggests, recyclerview are recycled view. Any view created is not a permanent view, once scrolled the view gets recycled and when you scroll back to the same position, it is created again.
The best way you can achieve this is to save the data (database or shared preference, as per your need) in the method onViewRecycled() and to populate that data back in onBindViewHolder()

ABS
- 1,101
- 10
- 27
0
if you want to save the state of a view after recreation. just assign it an Id;

Ehsan.sarshar
- 119
- 1
- 1
- 6
-
-
-
That al are done previously, when I scrolled down recycler view value is reset – Aug 26 '17 at 09:11
-
recycler view is working as it's name. it recycle your previous view. – Ehsan.sarshar Aug 26 '17 at 09:15
-
when scroll down, new views will attach to your recycle view. and when then go up it will recycle your previous view. – Ehsan.sarshar Aug 26 '17 at 09:17
-
how can i save the value of editteext, i have more than 10 edit text data load from server – Aug 26 '17 at 09:18
-
and recycling mean creating from scratch. and if u assign it and id it will restore the previous state of your view . but not your view attached data – Ehsan.sarshar Aug 26 '17 at 09:19
-
-
-
-
-
-