RecyclerView的item中有EditView问题

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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值