I have a recycler view
with 2 view types, 1 is just a textview
another is just an edittext
. The edittext
is always at the bottom of the recycler view below the text. When I am typing in the edittext and scroll up, the edittext
is recycled but is it possible to keep it from being recycled and allow users to keep typing after scrolling up?
Asked
Active
Viewed 376 times
1

Rgfvfk Iff
- 1,549
- 2
- 23
- 47
-
Please share your layout code for better understanding of your requirement and to see what you implemented so far. – Nishant Dubey Jul 25 '18 at 05:09
-
check this answer **[recyclerView with edittext](https://stackoverflow.com/a/47975852/7666442)** – AskNilesh Jul 25 '18 at 05:11
2 Answers
1
If you need to disable view recycling (and you understand the tradeoffs), you are better off using a LinearLayout and adding views at runtime to it.

Udit
- 1,037
- 6
- 11
1
If you want to user recycler view and also want to retain entered text, you have to use TextWatcher(https://developer.android.com/reference/android/text/TextWatcher) and need to save changed text in your collection object.
editTextInstance.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
collcectionInstance.get(position).setName(s);
}
});

Karan Rana
- 638
- 4
- 14