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?
答案 0 :(得分: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.
答案 1 :(得分: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);
}
});