[英]Custom DialogPreference in Android
In My Project I am using SeekBarPreference
. 在我的项目中,我正在使用SeekBarPreference
。 I take reference from http://android.hlidskialf.com/blog/code/android-seekbar-preference code work perfect without any error but when i fetch share Preference value in other activity. 我从http://android.hlidskialf.com/blog/code/android-seekbar-preference代码取得了参考,代码完美无误,但是当我在其他活动中获取共享Preference值时。 then i always found 0 why? 那么我总是发现0为什么? I use below code for get share Preference value:- 我将以下代码用于获取共享首选项值:-
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String str=Integer.toString( prefs.getInt("duration", 0));
Using Shared preferences code for get and put the values below: 使用共享首选项代码获取和放置以下值:
code for put the values into sharedpreferences: 将值放入sharedpreferences的代码:
public static final String PREFS_NAME = "Prefs";
SharedPreferences settings = getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("no", 11);
editor.commit();
Code for get the values from sharedpreferences: 用于从sharedpreferences获取值的代码:
SharedPreferences settings = getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
String in=Integer.toString(settings.getInt("no", 0));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.