Reputation: 11
Is there any way for me to save the position of the thumb where i have moved to before i leave the fragment which is contenting that SeekBar ? Thanks.
Upvotes: 1
Views: 339
Reputation: 14835
You need to save the position of the Seekbar
in SharedPreference
and then retrieve it later.
Here is the simple example
EXAMPLE:
SharedPreference mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
Editor mEditor = mSharedPrefs.edit();
int mProgress = mSeekBar.getProgress();
mEditor.putInt("SeekBarPosition", mProgress).commit();
and then retrieve them like this
int mProgress = mSharedPrefs.getInt("mMySeekBarProgress", 0);
mSeekBar.setProgress(mProgress);
Upvotes: 3