Hello,
Welcome to our Microsoft Q&A platform!
Since the returned type of function imageView.Drawable.GetState()
is a list, and If you want to use SharedPreferences to save the status of your ImageView, you can try to use JsonConvert
to convert it to a string and save this string into SharedPreference
.
You can refer to the following code:
1.Save value:
int[] states = imageView.Drawable.GetState();
string mstr = JsonConvert.SerializeObject(states);
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
ISharedPreferencesEditor editor = prefs.Edit();
editor.PutString("states", mstr);
editor.Apply();
2.access value:
ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
string mString = prefs.GetString("states", "");
var mList = JsonConvert.DeserializeObject<List<int>>(mString);
Toast.MakeText(this, " The first status" + mList[0] ,ToastLength.Long).Show();
Best Regards,
Jessie Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.