preferenceactivity

How to show and hide preferences on Android dynamically?

淺唱寂寞╮ 提交于 2019-11-30 10:46:30
问题 Is there a way to dynamically show and hide preferences? In my case, I have a checkbox preference that would disable or enable one of 2 preference groups ("with-" and "without-handicap" groups). While this would be the ideal GUI in a desktop environment, the "with-handicap" takes up nearly the whole screen, while the other, "without-handicap" takes up only a small portion of the screen. Rather than showing both groups at the same time, I'd like to show only one of them at a time, and

Change PreferenceActivity text color

坚强是说给别人听的谎言 提交于 2019-11-30 09:27:46
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) 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 name="Theme.DarkText"> <item name="android:textColor">#000000</item> </style> </resources> Afterwards set it

How do you refresh PreferenceActivity to show changes in the settings?

六月ゝ 毕业季﹏ 提交于 2019-11-30 06:52:42
问题 Based on the following code, can you tell me how to refresh the PreferenceActivity window to show changes in the settings immediately? For example: the user taps the master chime toggle checkbox to true (ticked), I would like the user to immediately see the other settings such as the ChimeOn15Past checkbox also be be true (ticked) SharedPreferences.Editor prefEditor = clockSettings.edit(); // Allow the settings to be changed. if (booleanMasterChimeToggle == true) { prefEditor.putBoolean(

Reload Preferences in PreferenceActivity on Resume

 ̄綄美尐妖づ 提交于 2019-11-30 03:41:16
问题 In my app, some settings can possibly be changed while the PreferenceActivity is not open, and an issue I'm running into is that addPreferencesFromResource is called in onCreate , so say, I open the PreferenceActivity , then go to another screen from there, then do something that changes the settings, then hit the back key to go back to the PreferenceActivity , then certain settings have not changed on the layout. So, how could I re-load all the Preferences every time onResume (or onStart() )

Skip the headers in PreferenceActivity when there's only one header

二次信任 提交于 2019-11-29 23:01:32
I added preference-headers to my app so that the preference screen would not look broken on Honeycomb and tablet sized ICS. However, I only have one header at the moment so you have to click through a header screen with only one entry on phone sized devices. Is there an easy way to tell android to skip the header screen when there's only one header, but to still show it on large screens? It seems that the stock Contacts app does this successfully but I've browsed through its source and can't figure out how it is doing it. jenzz You can skip the headers by setting one of your

How to show and hide preferences on Android dynamically?

烂漫一生 提交于 2019-11-29 22:15:02
Is there a way to dynamically show and hide preferences? In my case, I have a checkbox preference that would disable or enable one of 2 preference groups ("with-" and "without-handicap" groups). While this would be the ideal GUI in a desktop environment, the "with-handicap" takes up nearly the whole screen, while the other, "without-handicap" takes up only a small portion of the screen. Rather than showing both groups at the same time, I'd like to show only one of them at a time, and dynamically show or hide the 2 groups when the checkbox changes. Is there a way to do this? dhaag23 From a

Preference Activity on Preference Click Listener

一个人想着一个人 提交于 2019-11-29 05:48:33
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:summary="Remove this device from the computer's whitelist" android:title="Remove this device from

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

自闭症网瘾萝莉.ら 提交于 2019-11-29 04:08:46
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 user enters sub-PreferenceScreen, and edits the account user-name, I want the outer PreferenceScreen

How do you refresh PreferenceActivity to show changes in the settings?

寵の児 提交于 2019-11-28 22:41:45
Based on the following code, can you tell me how to refresh the PreferenceActivity window to show changes in the settings immediately? For example: the user taps the master chime toggle checkbox to true (ticked), I would like the user to immediately see the other settings such as the ChimeOn15Past checkbox also be be true (ticked) SharedPreferences.Editor prefEditor = clockSettings.edit(); // Allow the settings to be changed. if (booleanMasterChimeToggle == true) { prefEditor.putBoolean("ChimeOnTheHour", true); prefEditor.putBoolean("ChimeOn15Past", true); prefEditor.putBoolean("ChimeOn30Past"

set custom font for text in PreferenceScreen

雨燕双飞 提交于 2019-11-28 21:53:38
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.ttf"); TextView about_txt = (TextView) findViewById(R.id.about_txt); about_txt.setTypeface(timesFont);