RecyclerView的item中有EditText,对EditText进行编辑后滑动列表,有时编辑的不起作用依旧显示之前的内容(缓存),有时编辑多条时显示内容错乱,每次滑动都会有不同的内容呈现,现象有点奇葩;下面是解决此问题的一种方式,以供参考;
RecyclerView源码中有这么一段话:
意思提示我们避免在item中使用EditText,并且小心处理能够获取到光标的view;
工作中之前也遇到过RecyclerView的item中EditeText编辑后滑动recyclerview出现错误的问题;
/* RecyclerView is calculating a scroll.
* If there are too many of these in Systrace, some Views inside RecyclerView might be causing
* it. Try to avoid using EditText, focusable views or handle them with care.
*/
代码很简单抓住点子
xml文件:里面就一个EditText
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
an