Gentlemen, this code does not work, CheckBox values are not saved, this code is in the RecyclerView adapter, I haven’t tried it already, nothing is working, please tell me how to make it work ?!
Thanks in advance!
//SharedPreferences
final SharedPreferences prefs = context.getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
final SharedPreferences.Editor editor = prefs.edit();
prefs.getBoolean("sName", false);
holder.sName4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(v != null) {
holder.sName5.setChecked(true);
holder.sName3.setTextColor(ContextCompat.getColor(context, R.color.Checked));
holder.sName4.setCardBackgroundColor(ContextCompat.getColor(context, R.color.colorCVA));
editor.putBoolean("sName", true);
editor.apply();
} else {
holder.sName5.setChecked(false);
holder.sName3.setTextColor(ContextCompat.getColor(context, R.color.lblListItem3));
holder.sName4.setCardBackgroundColor(ContextCompat.getColor(context, R.color.colorCVNA));
editor.putBoolean("sName", false);
editor.apply();
}
}
});
And then how to get data?
Aucun commentaire:
Enregistrer un commentaire