android-preferences

preference activity listener in android

…衆ロ難τιáo~ 提交于 2019-12-11 17:38:30
问题 I am using the following code for adding a listener in prefernceactivity. But its not working. Please give a idea for this. public class Preference extends PreferenceActivity implements OnSharedPreferenceChangeListener { OnSharedPreferenceChangeListener listener; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,

How to open up phones settings page through preferences?

99封情书 提交于 2019-12-11 16:26:28
问题 I am making a settings page for an app and one of the features I want is for the user to change the permissions through the settings page by redirecting to the users phones settings. I am trying to figured out how to do that programmatically. I am wondering if it can be done like the same way as android.intent.action.VIEW through the preference like I show in the example or is there a different procedure I have to follow. <Preference android:title="Example"> <intent android:action="android

Can Android Preferences/Settings screen be configured to use preferences other than 'DEFAULT' shared preferences?

℡╲_俬逩灬. 提交于 2019-12-11 13:46:22
问题 Android Tutorials and examples show how to use Preference Fragment and Preference Activity to create Settings screen in an app. However, all preferences exposed this way get their values to ' DefaultSharedPreferences '. What if we want to save preference values to other (non-default / custom) SharedPreferences. The use case I have in mind is similar to email apps where an app may allow the user to create multiple accounts, and also give the user options to save settings for different accounts

Customizing preference headers layout

时光怂恿深爱的人放手 提交于 2019-12-11 12:49:45
问题 I am using the SettingsActivity generated from AndroidStudio ( New , Activity , Settings Activity ) that relies on AppCompatDelegate. I have succeeded to add a toolbar and to set a custom divider to the listview used for displayer preference headers as follows: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout root = (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent(); Toolbar toolbar = (Toolbar)

Custom PreferenceScreen in PreferenceScreen

社会主义新天地 提交于 2019-12-11 11:33:44
问题 I have a standard preference page in my app. But from this preference page i want the user to be able to navigate to an other PreferenceScreen with a custom layout, when user presses "Manage Favorits. This is the custom layout i have in mind: Is it possible to use custom layout on "sub-preference-screens"? Thanks! 回答1: Yes, you can launch a separate activity using intent . <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen android:title="@string

TextView setText doesn't work on custome layout in PreferenceFragment

时光怂恿深爱的人放手 提交于 2019-12-11 10:38:56
问题 I'm using PreferenceFragment with some default preferences categories and one custom layout: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:key="first_category" android:title="config" > <EditTextPreference android:defaultValue="example" android:dialogMessage="text" android:dialogTitle="Title" android:key="mykey" android:summary="summary" android:title="title" /> <Preference android:key="test

ClassCastException from a PreferenceActivity

我的未来我决定 提交于 2019-12-11 08:26:55
问题 I'm getting a classCastException every time I try to use this preference class, and I can't figure out why. Any help would be much appreciated. The line the crashes is the addPreferencesFromResources command. import android.os.Bundle; import android.preference.PreferenceActivity; public class PreferenceManager extends PreferenceActivity { @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate

How to make a Preference not save to SharedPreferences?

别等时光非礼了梦想. 提交于 2019-12-11 06:48:56
问题 I am re-using ListPreference for a setting which I store only in the database. How can I prevent it from storing/persisting any data to the preference file? 回答1: Subclass it, override shouldPersist() to return false. 回答2: I've not done it myself, but have you looked into overriding onDialogClosed() ? 来源: https://stackoverflow.com/questions/2488830/how-to-make-a-preference-not-save-to-sharedpreferences

How to store and retrieve an object from Gson in android? [duplicate]

人走茶凉 提交于 2019-12-11 05:42:17
问题 This question already has answers here : Gson - convert from Json to a typed ArrayList<T> (5 answers) Closed 3 years ago . In my activity, the user has an array of images he picks, and then I want to store them in preferences. Then the user leaves the activity, and comes back, I want those images still loaded into an ImageView . I'm trying to use Gson to accomplish this, but am having trouble and can't see what I'm doing wrong. Hoping external insight may help me with this obvious answer I'm

Resource not found: res/drawable/list_selector_background.xml?

二次信任 提交于 2019-12-11 05:17:06
问题 I recently released my first app. Having only tested in SDK emulator and on a Galaxy S2, the feedback about devices it works on coming to me has been great. Unfortunately I've had a couple users report FCs to me. The common factor between them is that they are both MIUI users (different devices IIRC). One has been very helpful in providing info and trying out sample builds to resolve the issue but I just can't seem to make any headway on it. I've searched online fairly extensively. Although I