1
我有一个回收视图和网格布局管理that.For充气以回收视图布局项目我设置背景颜色像这样回收站查看项目不改变其颜色
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:orientation="vertical">
<TextView
android:id="@+id/regNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.9"
android:background="@drawable/student_li_bgcolor"
android:gravity="center"
android:padding="7dp"
android:clickable="true"
android:text="15BEC0584"
android:textColor="#64DD17"
android:textSize="17dp" />
</LinearLayout>
student_li_bgcolor的含量这
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true">
<shape>
<solid
android:color="#64DD17"
/>
</shape>
</item>
<item
android:state_pressed="true"
>
<shape>
<solid
android:color="#ffffff"
/>
</shape>
</item>
<item
android:state_selected="false"
>
<shape>
<solid
android:color="#ffffff"
/>
</shape>
</item>
</selector>
我想达到什么目的是改变项目的颜色为绿色,如果用户至少按下它。
有了这个代码
<item
android:state_pressed="true"
>
<shape>
<solid
android:color="#ffffff"
/>
</shape>
</item>
<item
android:state_pressed="false"
>
<shape>
<solid
android:color="#ffffff"
/>
</shape>
</item>
我能够改变背景颜色click.But其尽快它。我上删除用户手指不想要that.Please帮我恢复到其原来的颜色...在此先感谢...
我已经尝试使用view.setBackground(Color.parseColor(“#000000”))其中视图是我们在recyclerview viewHolder之一得到的一个 – bharath
但它对我无用 – bharath
你可以显示你的代码onClickListener ),以便我可以尝试并给你一些反馈。 – Paul