android-preferences

What is the file name used by default shared preferences?

∥☆過路亽.° 提交于 2019-12-09 14:23:45
问题 Android Backup Service requires a filename to backup shared preferences: public static final String PREFS = "PrefFile"; SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, PREFS); It is clear what to use if filename is given during preferences creation like public static final String PREF_FILE_NAME = "PrefFile"; SharedPreferences preferences = getSharedPreferences(PREF_FILE_NAME, MODE_PRIVATE); But I use default shared preferences: SharedPreferences preferences =

Add a Button into PrefrenceScreen : Android

删除回忆录丶 提交于 2019-12-09 14:00:01
问题 Hi i want to add a button into prefrencescreen, i got success into add a button into the prefrence but i could not get onClick event. i have attached my code a pic of prefence screen setting.xml <PreferenceCategory android:title="Application Details"> <Preference android:key="type" android:title="Type" android:summary="" /> </PreferenceCategory> <PreferenceCategory android:title="Notification Settings"> <ListPreference android:key="sendNotificationType" android:title="Status Notification For"

How to get an Android ListPreference defined in Xml whose values are integers?

爱⌒轻易说出口 提交于 2019-12-09 07:57:12
问题 Is it possible to define a ListPreference in Xml and retrieve the value from SharedPreferences using getInt? Here is my Xml: <ListPreference android:key="@string/prefGestureAccuracyKey" android:title="@string/prefGestureAccuracyTitle" android:summary="@string/prefGestureAccuracyDesc" android:entries="@array/prefNumberAccuracyLabels" android:entryValues="@array/prefNumberAccuracyValues" android:dialogTitle="@string/prefGestureAccuracyDialog" android:persistent="true" android:defaultValue="2"

[Android]How to get results from intent launched from preference screen?

与世无争的帅哥 提交于 2019-12-09 05:57:48
问题 I need help in geting results back from intent launched from preference screen // Intent preference DevicePref = getPreferenceManager().createPreferenceScreen(this); // Show a Screen with list of Devices Discovered Intent i = new Intent(this,getDevice.class); DevicePref.setIntent(i); DevicePref.setTitle("Select Device"); DevicePref.setSummary(mSelectedDevice); deviceOptionsCat.addPreference(DevicePref); I want user to select device... In preference screeen I show "Select Device" .. when user

How to use EditTextPreference as a masked Password text field?

廉价感情. 提交于 2019-12-09 04:38:42
问题 I have a very simple question: I have a EditTextPreference dialog which I want to use for getting the user's password and I want it to be masked. How can I do that? 回答1: Here is a short example using xml: <EditTextPreference android:key="@string/key" android:title="@string/title" android:summary="@string/summary" android:inputType="textPassword" /> Or you can use numberPassword instead of textPassword . 回答2: android:inputType="numberPassword" doesn't work for me. Eclipse told me, that no

findViewById returns null for preference layout

对着背影说爱祢 提交于 2019-12-08 18:23:12
问题 I have a preference screen (responder_generic.xml) as follows: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <Preference android:defaultValue="false" android:key="auto_responder_key" android:layout="@layout/preference_header_switch_item_responder" android:title="@string/auto_responder"> </Preference> </PreferenceScreen> which i am instantiating as follows : (in version 2.3.3) addPreferencesFromResource(R.xml.responder

No static field list_container of type I in class Landroid/support/v7/preference/R$id

ぃ、小莉子 提交于 2019-12-08 15:33:36
问题 I migrated a project of 2 years old to Android Studio (and the new lib), I have a lot of problems when I call a PreferenceScreen. java.lang.NoSuchFieldError: No static field list_container of type I in class Landroid/support/v7/preference/R$id; or its superclasses (declaration of 'android.support.v7.preference.R$id' appears in /data/app/com.sh.inv-1/base.apk) at android.support.v7.preference.PreferenceFragmentCompat.onCreateView(PreferenceFragmentCompat.java:260) at android.support.v4.app

Android MultiSelectListPreference, java.lang.String cannot be cast to java.util.Set

白昼怎懂夜的黑 提交于 2019-12-08 14:56:10
问题 I try to implement MultiSelectListPreference for my settings view: <MultiSelectListPreference android:title="@string/title" android:summary="@string/message" android:key="pref_foobar" android:defaultValue="@array/empty_array" android:entries="@array/fooArray" android:entryValues="@array/fooValues" /> The array: <resources> <string-array name="fooArray"> <item>Foo</item> <item>Bar</item> </string-array> <string-array name="fooValues"> <item>foo_value</item> <item>bar_value</item> </string

Android: addView(View) is not supported in AdapterView

空扰寡人 提交于 2019-12-08 09:34:47
问题 I've got a PreferenceFragment that displays a dynamic list of preferences, implemented like this; public class ConfigFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); for(int i = 0; i<items.size();i++) { SettingsScreen s = new SettingsScreen(getActivity()); PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity()); screen.setTitle

Embed Listview into Preferences in Android

只谈情不闲聊 提交于 2019-12-08 04:41:20
问题 I need to show a list in Preferences view, so I created my own class (inherit of Preference ) and then set it like this: @Override protected View onCreateView(ViewGroup parent){ cards = new ArrayList<String>(); // Test cards.add("4859-2368957415"); cards.add("4859-5987412598"); LinearLayout layout = new LinearLayout(getContext()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); layout