Android RecyclerView-物品的按下状态变得混乱
我创建了一个Android RecyclerView-物品的按下状态变得混乱,android,android-recyclerview,Android,Android Recyclerview,我创建了一个RecyclerView,如下所示: recyclerView.setLayoutManager(new GridLayoutManager(getContext(), cols, LinearLayoutManager.VERTICAL, stickToBottom); recyclerView.setAdapter(adapter); // completely disable animations... just to test if this solves the prob
RecyclerView
,如下所示:
recyclerView.setLayoutManager(new GridLayoutManager(getContext(), cols, LinearLayoutManager.VERTICAL, stickToBottom);
recyclerView.setAdapter(adapter);
// completely disable animations... just to test if this solves the problem
recyclerView.setItemAnimator(null);
我长按图标并开始滚动,有时,这会导致循环视图看起来被按下。。。我在我的recyclerview项目上使用了一个简单的“android:background=“?android:attr/selectableItemBackground”
我该如何解决问题,或者问题的根本原因是什么
一些事实
- 循环使用视图效果很好,文本和图像应该更新
- 只有背景不会重置,即使未触摸项目,也会显示为按下状态
- 我在
中使用的是WindowManager
,而不是在活动中RecyclerView
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:drawable="@color/white" />
<item android:state_pressed="true" android:drawable="@color/highlight_color" />
</selector>
将此可绘制设置为您使用过的row_布局。它会起作用。我已经尝试了一个不带动画的可绘制布局…但它并不能解决问题。我的想法是,选择器中的动画会产生问题…@prom85它对我起作用。我为RecycleServiceAndroid:cl使用此和其他内容执行了拖放功能ickable=“true”android:focusable=“true”