android-preferences

defaultValue from xml preference file isn't stored - why?

浪子不回头ぞ 提交于 2019-12-10 19:45:37
问题 When the application is first startet, I'd like to store all default values I've defined in my prefences.xml by using the 'android:defaultValue' attribute, but some of them are not stored on the device - can someone tell me why? <?xml version="1.0" encoding="utf-8"?> <PreferenceCategory android:title="@string/prefs_cat_title_x"> <ListPreference android:key="@string/prefs_key_1" android:title="@string/prefs_title_1" android:summary="@string/prefs_summary_1" android:entries="@array/array1"

Add a button to the bottom of Preferences Screen

穿精又带淫゛_ 提交于 2019-12-10 19:09:13
问题 Despite the content of the comment of @stealthcopter (check answer made by @Andrew) in this question How to add a button to PreferenceScreen, I am not able to visualise a button in the bottom part of my activity. The application .apk will crash with the following error: Unfortunately your_app has stopped working! Here is the stack trace from the crash: 05-25 21:26:39.431: I/dalvikvm(1405): threadid=3: reacting to signal 3 05-25 21:26:39.462: I/dalvikvm(1405): Wrote stack traces to '/data/anr

Checkbox Preference and Checking if its enabled or disable

我的未来我决定 提交于 2019-12-10 13:58:28
问题 Im having issues with the below code on making a checkbox preference, That by default is checked. My first activity is a simple splash screen, and simply before show my imageview thread i want to check if the checkbox has been disable if so then i want to intent directly to the main activity and by default i show my image thread, or in reversed order of that. Currently my splashscreen is launching no matter if its checked or now, Any help would be greatly appreciated XML <CheckBoxPreference

Preference List only shows first element

不问归期 提交于 2019-12-10 13:53:43
问题 I am developing a PreferenceActivity with custom Preference views. My problem is that I created a view with a ListView and it only shows the first element. I post my code and an image: http://imageshack.us/photo/my-images/545/sc20120307161530.png/ http://img545.imageshack.us/img545/7207/sc20120307161530.png' border='0'/> xml: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:key="player_settings"

“In-place” EditTextPreference

非 Y 不嫁゛ 提交于 2019-12-10 12:01:44
问题 I used the XML syntax to create a PreferenceActivity with a PreferenceScreen . I added an EditTextPreference and noticed that this renders as a dialog. Is there a way to make the EditText in-place i.e., the text field is displayed right in the PreferenceScreen instead of popping up as a dialog? 回答1: In case anyone comes across the same problem, this cannot be accomplished with the built-in Preference classes, but you can subclass Preference , and override getView() to return a ViewGroup

Change Activity Theme From a Fragment

不问归期 提交于 2019-12-10 10:57:49
问题 I have a settings PreferenceFragment that allows the user to select a theme. The user can select a dark or light theme. After selecting a theme the user presses the back button to return to the previous fragment. This called the containing activity's onCreate method where the theme is read and applied. However the theme is not applied correctly, Switching from Holo.Light to Holo.Dark changes the background colour, action bar etc but does not change the text resulting in faded, hard to read

How to load the same screen preference in the detail PreferenceFragment

核能气质少年 提交于 2019-12-10 04:21:27
问题 I am trying to do something like the settings preferences in android for tablet. When I click the "More" the the "Wireless & Networks" preferences screen is displayed on the right fragment, than if I touch the "VPN" , in the same fragment the "VPN" preferences screen is opened. How can I do that ? this is my preference xml <PreferenceScreen android:title="Title A"> <PreferenceScreen android:title="TITLE B"> <PreferenceCategory android:title="category"> <ListPreference android:key="list"

getDefaultSharedPreferences in a BroadcastReceiver

风流意气都作罢 提交于 2019-12-10 00:53:53
问题 I was just guessing how to access the DefaultSharedPreferences (set in a PreferenceActivity) from an application in a BroadcastReceiver, knowing that onReceive method comes with Context and Intent? Best regards, 回答1: In the BroadcastReceiver: PreferenceManager.getDefaultSharedPreferences(context) 回答2: Looking at the source of it, we can see getDefaultSharedPreferences actually uses getSharedPreferences. So we can use getSharedPreferences the same we getDefaultSharedPreferences uses it. In

setText not working for EditTextPreference

China☆狼群 提交于 2019-12-10 00:25:32
问题 I'm trying to set value for EditTextPreference item with hostPreference.setText("Not yet set"); But text is not showing I want to show it like Use Name here public class HostSettingActivity extends PreferenceActivity { private final String MY_DEBUG_TAG = "SettingActivity"; SharedPreferences sharedPrefs; @Override protected void onCreate(Bundle savedInstanceState) { Log.i(MY_DEBUG_TAG, "HostSettingActivity Started"); super.onCreate(savedInstanceState); sharedPrefs = getPreferenceManager()

PreferenceFragment overlaps toolbar

最后都变了- 提交于 2019-12-09 18:15:11
问题 As the title, my PreferenceFragment overlaps my toolbar. I've already tryed different solutions but the problem persists. Hopes in any help. Here is my code. Activity: import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; public class MyActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar =