将类似按钮的操作保存在缓存中

问题描述 投票:0回答:1

我创建了一个应用,用户可以喜欢每个帖子。像三星音乐一样:

enter image description here

而且我在具有布尔条件的imageview上使用onclicklistener喜欢或不喜欢它。

我想将类似操作保存在共享共享或sqlite或...之类的应用程序缓存中后保存。我知道我可以使用服务器中的用户ID来执行此操作,但是在我的应用程序中,用户未注册,并且无需注册即可使用它。所以我想保存此操作以进行缓存。如果有可能,请指导我。

android sqlite button sharedpreferences onclicklistener
1个回答
0
投票

根据您的情况,使用自定义复选框会更好。

<CheckBox
android:id="@+id/likeIcon"
style="@style/ThumbIconStyle"
android:background="@drawable/selector_like"
android:stateListAnimator="@animator/scale" />

背景为选中状态和未选中状态的选择器状态。动画师/比例尺是动画师状态列表。

© www.soinside.com 2019 - 2024. All rights reserved.