android-preferences

OnPreferenceChangeListener for every setting

≡放荡痞女 提交于 2019-12-13 11:48:34
问题 I know that I can do something like this: Preference pref = findPreference(getString(R.string.pref_vibrate_on_key)); pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { LogUtil.d("Working!"); return true; } }); But I would like to add a Listener to every preference. I tried doing: SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp

How to use preferences in Android support library v7 rev23?

江枫思渺然 提交于 2019-12-13 11:25:52
问题 In my app using support library v7 I want to add a preference screen. Since Google provides absolutely no documentation on that subject I have looked up a post found elsewhere here on Stack Overflow. So this is my project: activity_preferences.xml <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:support="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android

Nested keying in SharedPreferences?

感情迁移 提交于 2019-12-13 07:29:29
问题 I need to be able to access multiple settings using one key. For example: <EditTextPreference android:key="@string/channel_url1" android:defaultValue="http://youtu.be/" /> <EditTextPreference android:key="@string/num_views1" android:defaultValue="0" /> <EditTextPreference android:key="@string/num_subs1" android:defaultValue="0" /> <EditTextPreference android:key="@string/channel_url2" android:defaultValue="http://you.tu/" /> <EditTextPreference android:key="@string/num_views2" android

Android Editable ListView (preference / dialog)

喜夏-厌秋 提交于 2019-12-13 06:46:46
问题 I need a editable list view with strings where items can be renamed added and removed. That should be - if possible in a preference view / dialog. What is the best way to implement that? Are there libs? - I didn't find any. My current solution is a multilined EditText dialog with one entry each line. 来源: https://stackoverflow.com/questions/36872319/android-editable-listview-preference-dialog

Custom Preference shows differently on Preference screen than native Preferences

℡╲_俬逩灬. 提交于 2019-12-13 03:43:05
问题 A picture is worth a thousand words, this is my problem: The last three preferences are a custom time picker for minutes and seconds The other settings are the normal SwitchPreference, RingTonePreference, ListPreference and EditTextPreference This is my preferences XML <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="@string/pref_header_general"> <SwitchPreference android:defaultValue="true"

Android N - Change Locale in runtime

大兔子大兔子 提交于 2019-12-13 03:18:38
问题 I have an android app to which I want to add a simple preferences screen with a single option to switch between to languages (english and portuguese). I have already the proper string resources files in place. If I change the main language of the OS in the system preferences, and reload the app, it will use that language, however I would like to be able to do it via the preferences screen. I saw in other questions here that in this was a lot easier to do in previous Android versions, but that

Fragment placed on top of NavigationDrawer

只谈情不闲聊 提交于 2019-12-12 13:38:31
问题 I'm trying to add a PreferenceFragment in my application. The problem is, it's auto placed on top of my NavigationDrawer . public class SetPreferenceActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.settings); navigationDrawer(); // Loads the NavigationDrawer getFragmentManager().beginTransaction().replace(android.R.id.content, new Settings()).commit(); } As

onSharedPreferenceChanged without using getDefaultSharedPreferences

我与影子孤独终老i 提交于 2019-12-12 10:28:02
问题 I'm using context.getSharedPreference instead of getDefaultSharedPreferences. Means : SharedPreferences checkboxSetting = context.getSharedPreferences( "myPreferenceDB", Context.MODE_PRIVATE); boolean flag = checkboxSetting.getBoolean("checkboxKey",true); And preference.xml : <CheckBoxPreference android:key="checkBoxPrefff" android:title="@string/title" android:defaultValue="true"/> Application setting has a checkboxpreference that I want to get the value of, checked or not checked. Will this

How to start preferenceActivity part way down the hierarchy

会有一股神秘感。 提交于 2019-12-12 10:18:54
问题 I am working at API level 9 so can not use the new Preference Fragment stuff. I have a preference activity getting the preferences from and xml file as per the api demos. I have a hierarchy of preference screens so normaly to get to a preference you have to click though a top level screen. As well as getting to all the preferences from my main menu I would like to be able to start the preference activity at one of the sub screens rather than the top screen so I can start it directly in one of

Change height of Preference items

[亡魂溺海] 提交于 2019-12-12 09:43:14
问题 I have a PreferenceFragment subclass. I want each one of its items (Preferences and SwitchPreferences) to have a height of 120dp. How to do that? Here is the related code: public class SettingsFragment extends PreferenceFragment { public SettingsFragment() {} @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.main); } } and <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas