preferenceactivity

Android get view of Preference in PreferenceActivity

淺唱寂寞╮ 提交于 2019-12-19 05:35:37
问题 I would like to get View instance that is used to display specific Preference in my PreferenceActivity, so i can modify its properties, for example: public class SettingsActivity extends PreferenceActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preference); Preference pref = findPreference("key"); pref.getView().setVisibility(View.GONE); //not necessarily setVisibility, i hope you get my point } } I only found

Android get view of Preference in PreferenceActivity

北慕城南 提交于 2019-12-19 05:35:32
问题 I would like to get View instance that is used to display specific Preference in my PreferenceActivity, so i can modify its properties, for example: public class SettingsActivity extends PreferenceActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preference); Preference pref = findPreference("key"); pref.getView().setVisibility(View.GONE); //not necessarily setVisibility, i hope you get my point } } I only found

Change PreferenceActivity text color

喜你入骨 提交于 2019-12-18 13:37:12
问题 I want to change the look of my Android app's preference screen to dark text color. How can I do this? (I´ve already changed the background to white color) 回答1: I assume you use an Activity which extends the PreferenceActivity . You can use the setTheme method to set a custom theme on your preference screen. Just define one in res/values/themes.xml . It would look like this: <?xml version="1.0" encoding="UTF-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style

SharedPreferences will not save/load in PreferenceActivity

回眸只為那壹抹淺笑 提交于 2019-12-18 12:25:17
问题 EDIT: The problem described below was due to a very peculiar device issue not caused by any coding-related problem. I have a preferenceActivity in which I have many checkBoxPreferences. The checkBoxPreference is suppose to save the the default shared preferences file, and then be called again when I open the app in order to update the UI. This does not happen like it's suppose to. If I close the app and open it back up, my values remain like they are suppose to, but if I use task manager to

Preference Activity on Preference Click Listener

你。 提交于 2019-12-18 04:33:24
问题 I am building a Preference Activity where most of the preferences in the list will be executing code and not modifying a SharedPreference directly. My preferences.xml file looks like this. <PreferenceCategory android:title="Connection" > <Preference android:id="@+id/settings_connectToNewComputer" android:key="connectToNewComputer" android:summary="Currently connected to:" android:title="Connect to new computer" /> <Preference android:id="@+id/removeDevice" android:key="removeDevice" android

Update existing Preference-item in a PreferenceActivity upon returning from a (sub)PreferenceScreen

允我心安 提交于 2019-12-18 04:12:49
问题 I have a PreferenceActivity with a bunch of (Sub)PreferenceScreens. Each such (Sub)PreferenceScreen represents an account and has the account-username as its title. PreferenceScreen root = mgr.createPreferenceScreen(this); for (MyAccountClass account : myAccounts) { final PreferenceScreen accScreen = mgr.createPreferenceScreen(this); accScreen.setTitle(account.getUsername()); // add Preferences to the accScreen // (for instance a "change username"-preference) ... root.add(accScreen); } As the

set custom font for text in PreferenceScreen

纵然是瞬间 提交于 2019-12-18 01:06:14
问题 My PreferenceActivity looks like: import android.os.Build; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.widget.TextView; public class Settings extends PreferenceActivity { @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.about); Typeface timesFont = Typeface.createFromAsset(getAssets(), "fonts/times

set custom font for text in PreferenceScreen

六月ゝ 毕业季﹏ 提交于 2019-12-18 01:05:30
问题 My PreferenceActivity looks like: import android.os.Build; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.widget.TextView; public class Settings extends PreferenceActivity { @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.about); Typeface timesFont = Typeface.createFromAsset(getAssets(), "fonts/times

Action Bar Home Button not functional with nested PreferenceScreen

耗尽温柔 提交于 2019-12-17 22:20:57
问题 I found a workaround to actually enable the ActionBar home button on the nested PreferenceScreen... however it doesn't call OnOptionsItemSelected in my PreferenceActivity. Anyone know a way to actually use the home button on a nested PreferenceScreen? Modification of post 35 here: http://code.google.com/p/android/issues/detail?id=4611 @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { super.onPreferenceTreeClick(preferenceScreen,

PreferenceActivity: save value as integer

北城以北 提交于 2019-12-17 21:43:30
问题 Using a simple EditTextPreference in my preferences activity: <EditTextPreference android:key="SomeKey" android:title="@string/some_title" android:summary="..." android:numeric="integer" android:maxLength="2" /> Is there a way that this configuration value would be saved as integer? Seems now it just allows to enter numbers, but the value is still saved as string: Calling: SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); int value = preferences.getInt(