I have a preferences.xml and Settings.java... In the onCreate method I want to set the summary of the preferences... Could someone guide me what is the best way to do it???
What I know is that one way of doing is
activityName_text = (EditTextPreference) findPreference("activityName");
activityName_text.setSummary(activityName_text.getText());
but for each key if I follow the above pattern I feel that the code will be bad...
Preferences.xml:
<PreferenceScreen android:title="Header" >
<EditTextPreference
android:defaultValue="TestRequest"
android:key="activityName"
android:title="activityName" />
<EditTextPreference
android:defaultValue="Request"
android:key="msgName"
android:title="msgName" />
<ListPreference
android:defaultValue="0"
android:entries="#array/msg_type"
android:entryValues="#array/msg_type_values"
android:key="msgType"
android:title="msgType" />
<EditTextPreference
android:defaultValue="AA"
android:key="senderURI"
android:title="senderURI" />
<EditTextPreference
android:defaultValue="BB"
android:key="destinationURI"
android:title="destinationURI" />
<EditTextPreference
android:defaultValue="AA"
android:key="replyToURI"
android:title="replyToURI" />
<EditTextPreference
android:defaultValue="BB"
android:key="originatorURI"
android:title="originatorURI" />
<EditTextPreference
android:defaultValue="FF"
android:key="failureReplytoURI"
android:title="failureReplytoURI" />
<EditTextPreference
android:defaultValue="AA"
android:key="correlationId"
android:title="correlationId" />
<EditTextPreference
android:defaultValue="HH"
android:key="security"
android:title="security" />
<EditTextPreference
android:defaultValue="GG"
android:key="securityType"
android:title="securityType" />
<EditTextPreference
android:defaultValue="HH"
android:key="priority"
android:title="priority" />
<ListPreference
android:defaultValue="0"
android:entries="#array/communicationPattern"
android:entryValues="#array/communicationPatternValues"
android:key="communicationPattern"
android:title="communicationPattern" />
<ListPreference
android:defaultValue="0"
android:entries="#array/communicationStyle"
android:entryValues="#array/communicationStyleValues"
android:key="communicationStyle"
android:title="communicationStyle" />
<EditTextPreference
android:defaultValue="100"
android:digits="0123456789"
android:key="requestedBatchSize"
android:title="requestedBatchSize" />
<!-- radhika-number format -->
<EditTextPreference
android:defaultValue="78"
android:digits="0123456789"
android:key="batchSequenceNumber"
android:title="batchSequenceNumber" />
<ListPreference
android:defaultValue="0"
android:entries="#array/batchSequenceEndOfReply"
android:entryValues="#array/batchSequenceEndOfReplyValues"
android:key="batchSequenceEndOfReply"
android:title="batchSequenceEndOfReply" />
<EditTextPreference
android:defaultValue="HH"
android:key="iteratorReferenceURI"
android:title="iteratorReferenceURI" />
<EditTextPreference
android:defaultValue="KK"
android:key="fileLocationURI"
android:title="fileLocationURI" />
<EditTextPreference
android:defaultValue="10/10/2010"
android:key="timestamp"
android:title="timestamp" />
<EditTextPreference
android:defaultValue="kkk"
android:key="vendorExtensions"
android:title="vendorExtensions" />
<PreferenceCategory
android:key="activityStatus"
android:title="activityStatus" >
<ListPreference
android:defaultValue="0"
android:entries="#array/activityStatusType"
android:entryValues="#array/activityStatusTypeValues"
android:key="actStatus"
android:title="activityStatus" />
<EditTextPreference
android:defaultValue="AA"
android:key="qualifier"
android:title="qualifier" />
</PreferenceCategory>
<PreferenceCategory
android:key="msgSpecificProperties"
android:title="msgSpecificProperties" >
<EditTextPreference
android:defaultValue="multiple values"
android:key="propName"
android:title="propName" />
<EditTextPreference
android:defaultValue="multiple values"
android:key="propValue"
android:title="propValue" />
</PreferenceCategory>
<PreferenceCategory
android:key="compressionType"
android:title="compressionType" >
<EditTextPreference
android:defaultValue="kkk"
android:key="compressionTypeAttr"
android:title="extension" />
<ListPreference
android:defaultValue="0"
android:entries="#array/compressionType"
android:entryValues="#array/compressionTypeValues"
android:key="compressionTypeValue"
android:title="value" />
</PreferenceCategory>
<PreferenceCategory
android:key="packingType"
android:title="packingType" >
<EditTextPreference
android:defaultValue="kkk"
android:key="packingTypeAttr"
android:title="extension" />
<ListPreference
android:defaultValue="0"
android:entries="#array/packingType"
android:entryValues="#array/packingTypeValues"
android:key="packingTypeValue"
android:title="value" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen android:title="Body" >
<PreferenceScreen android:title="Managed Elements" >
<PreferenceCategory
android:key="mdOrMlsnRef"
android:title="md Or Mlsn Ref" >
<EditTextPreference
android:defaultValue="Name"
android:key="rdnName"
android:title="rdnName" />
<EditTextPreference
android:defaultValue="Value"
android:key="rdnValue"
android:title="rdnValue" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen android:title="Active Alarms" >
</PreferenceScreen>
</PreferenceScreen>
</PreferenceScreen>
Settings.java:
package com.example.settingstest;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
public class Settings extends PreferenceActivity implements OnSharedPreferenceChangeListener {
EditTextPreference activityName_text;
EditTextPreference msgName_text;
#SuppressWarnings("deprecation")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
#Override
protected void onResume() {
super.onResume();
getPreferenceScreen().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
}
#Override protected void onPause() {
super.onPause();
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Preference p = findPreference(key);
if(p instanceof EditTextPreference)
{
p.setSummary(sharedPreferences.getString(key, (String)p.getSummary()));
}
else if(p instanceof ListPreference)
{
p.setSummary((String)((ListPreference) p).getEntry());
}
}
}
Use like this its always better to set summary from prefrence.xml, I am giving one example I am using this code and its working perfectly
<PreferenceCategory
android:key="dbh_social"
android:title="We know you are social" >
<Preference
android:key="dbh_invite"
android:summary="Invite your friends"
android:title="Invite Facebook Friends" />
<Preference
android:key="dbh_wall_post"
android:summary="Post about us on your Facebook wall "
android:title="Post on Facebook Wall" />
</PreferenceCategory>
You can put all your keys into a string-array resource and iterate over it on onCreate()
final String[] keys = getResources().getStringArray(R.array.keys) ; // all your keys here
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
for (int i = 0; i < keys.length; i++) {
setPreferenceSummary(p, keys[i]);
}
private void setPreferenceSummary(SharedPreferences sharedPreferences, String key) {
final Preference p = findPreference(key);
if(p instanceof EditTextPreference)
{
p.setSummary(sharedPreferences.getString(key, (String)p.getSummary()));
}
else if(p instanceof ListPreference)
{
p.setSummary((String)((ListPreference) p).getEntry());
}
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
setPreferenceSummary(sharedPreferences, key);
}
Related
I want to increase size of preference categaory title programmatically so how can do this ?
below is my xml
<PreferenceCategory android:title="#string/languagetitle"
android:key="LanguageCategory">
<ListPreference
android:defaultValue="#string/defaultlanguagevalue"
android:entries="#array/language"
android:entryValues="#array/languagevalues"
android:key="language"
android:summary="#string/languageSubtitle"
android:title="English" /></PreferenceCategory>
<PreferenceCategory android:title="#string/Notificationtitle"
android:key="NotificationCategory">
<SwitchPreference
android:defaultValue="true"
android:key="notification"
android:summary="#string/NotificationSubtitle"
android:title="#string/Notificationcontent" />
<ListPreference
android:entries="#array/time"
android:entryValues="#array/time"
android:key="time"
android:summary="#string/NotificationSubtitleTime"
android:title="#string/NotificationcontentTime"
android:defaultValue="9am"
/>
</PreferenceCategory>
<PreferenceCategory
android:title="#string/FontTitle"
android:key="FontStyleCategory"
>
<faisal.home.com.tafaqquhfiddin.FontStylePreference
android:key="fontstyle"
/>
<faisal.home.com.tafaqquhfiddin.FontSizePreference
android:key="fontsize"
/>
</PreferenceCategory>
<PreferenceCategory
android:title="#string/OTHERS"
android:key="FontSizeCategory">
<faisal.home.com.tafaqquhfiddin.About_us_Preference/>
</PreferenceCategory>
</PreferenceScreen>
and below is my code where i want to increase its size programmatically
public void OnLanguageChange()
{
SharedPreferences sharedPreferences= PreferenceManager.getDefaultSharedPreferences(getActivity());
PreferenceCategory languageCategory =(PreferenceCategory) findPreference("LanguageCategory");
Preference language =findPreference(MyAppManager.LANGUAGE_KEY);
PreferenceCategory notificationCategory =(PreferenceCategory) findPreference("NotificationCategory");
Preference notification =findPreference(MyAppManager.NOTIFICATION_KEY);
Preference notificationTime =findPreference(MyAppManager.NOTIFICATION_TIME_KEY);
PreferenceCategory fontStyleCategory=(PreferenceCategory)findPreference("FontStyleCategory");
PreferenceCategory fontSizeCategory=(PreferenceCategory)findPreference("FontSizeCategory");
languageCategory.setTitle(getString(R.string.languagetitle));
language.setSummary(getString(R.string.languageSubtitle));
notificationCategory.setTitle(getString(R.string.Notificationtitle));
notification.setTitle(getString(R.string.Notificationcontent));
notification.setSummary(getString(R.string.NotificationSubtitle));
notificationTime.setTitle(getString(R.string.NotificationcontentTime));
notificationTime.setSummary(getString(R.string.NotificationSubtitleTime)+" "+ sharedPreferences.getString(MyAppManager.NOTIFICATION_TIME_KEY, "9am"));
fontStyleCategory.setTitle(getString(R.string.FontTitle));
fontSizeCategory.setTitle(getString(R.string.FontSize));
}
I am new to android. Please help me how can i achieve this
I am trying to figure out why the layout of my Preference menu is displayed in a false way on 10' tablets when using it in landscape mode. It looks like the lines that are to the right of the Checkboxes are actually to the left of them. You can see this here http://imageshack.us/photo/my-images/109/schnappschuss2013052109.png/
On 7' tablets, everything works like expected to do.
My menu looks like that:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
android:title="#string/pref_message"
android:key="pref_key_message_settings">
<CheckBoxPreference
android:key="pref_key_add_timestamp"
android:summary="#string/pref_summary_addTimestamp"
android:title="#string/pref_addTimestamp"
android:defaultValue="true"/>
<ListPreference
android:dependency="pref_key_add_timestamp"
android:summary="#string/pref_summary_timestamp_option"
android:key="pref_key_timestamp_option"
android:title="#string/pref_timestampOption"
android:dialogTitle="#string/pref_timestampOptionDialog"
android:entries="#array/pref_timestampArray"
android:entryValues="#array/pref_timestampValues"
android:defaultValue="Time" />
<CheckBoxPreference
android:key="pref_key_add_newline"
android:summary="#string/pref_summary_addNewLine"
android:title="#string/pref_addNewLine"
android:defaultValue="true"/>
<ListPreference
android:dependency="pref_key_add_newline"
android:key="pref_key_newline_option"
android:summary="#string/pref_summary_newline_option"
android:title="#string/pref_newLineOption"
android:dialogTitle="#string/pref_newLineOptionDialog"
android:entries="#array/pref_newLineArray"
android:entryValues="#array/pref_newLineValues"
android:defaultValue="LF" />
<CheckBoxPreference
android:key="pref_key_clear_text"
android:summary="#string/pref_summary_clearText"
android:title="#string/pref_clearText"
android:defaultValue="false"/>
</PreferenceCategory>
<PreferenceCategory
android:title="#string/pref_storage"
android:key="pref_key_storage_settings">
<EditTextPreference
android:key="pref_key_change_name"
android:summary="#string/pref_summary_editFilename"
android:title="#string/pref_editFilename"
android:defaultValue="history"/>
<CheckBoxPreference
android:key="pref_key_add_date"
android:summary="#string/pref_summary_addDate"
android:title="#string/pref_addDate"
android:defaultValue="true"/>
<CheckBoxPreference
android:key="pref_key_add_time"
android:summary="#string/pref_summary_addTime"
android:title="#string/pref_addTime"
android:defaultValue="true"/>
<at.rtcmanager.ConfirmPreference
android:key="pref_key_clear_history"
android:summary="#string/pref_summary_clearHistory"
android:title="#string/pref_clearHistory"/>
</PreferenceCategory>
<PreferenceCategory
android:title="#string/pref_time"
android:key="pref_key_time_settings">
<CheckBoxPreference
android:key="pref_key_autosend_time"
android:summary="#string/pref_summary_austosendTime"
android:title="#string/pref_autosendTime"
android:defaultValue="false"/>
<ListPreference
android:key="pref_key_mode_sentTime"
android:title="#string/pref_mode_sentTime"
android:summary="#string/pref_summary_mode_sentTime"
android:dialogTitle="#string/pref_modeSentTimeDialog"
android:entries="#array/pref_sentTimeModeArray"
android:entryValues="#array/pref_sentTimeValues"
android:defaultValue="10Byte" />
</PreferenceCategory>
<PreferenceCategory
android:title="#string/pref_about"
android:key="pref_key_settings_about">
<Preference android:title="#string/prefs_about_app" >
<intent android:action="AboutActivity"/>
</Preference>
</PreferenceCategory>
</PreferenceScreen>
and is loded with:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Show the Up button in the action bar.
getActionBar().setDisplayHomeAsUpEnabled(true);
// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsMenuFragment())
.commit();
}
public static class SettingsMenuFragment extends PreferenceFragment {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.app_prefs);
}
}
I had the same problem. My solution is to extend SettingsActivity from usual Activity, not from PreferenceActivity. But SettingsFragment should extend PreferenceFragment of course. It helped me, hope this solves your issue too.
i'm using this code in an activity
protected void onResume() {
super.onResume();
prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
System.out.println(connections);
String dir = prefs.getString("download_directory", "Download");
System.out.println(dir);
}
My preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="Downloads">
<EditTextPreference
android:key="download_directory"
android:title="#string/download_destination"
android:summary="#string/download_description"
android:defaultValue="FacebookPhotos"
android:dialogTitle="#string/download_destination" />
<CheckBoxPreference android:key="subdir_album"
android:title="#string/download_album"
android:summary="#string/download_album_description" />
</PreferenceCategory>
<PreferenceCategory android:title="Gallery">
<EditTextPreference
android:key="connections"
android:title="Concurrent connections"
android:numeric="integer"
android:maxLength="2"
android:defaultValue="7"
android:dialogTitle="Concurrent connections" />
</PreferenceCategory>
</PreferenceScreen>
edited by
public class Preferences extends PreferenceActivity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
The problem is, when i get "connections" value it gives me the correct int, instead the getString for key "download_directory" always gives me the default value "Download"
getString for key "download_directory" always gives me the default
value "Download"
This can only happen if "download_directory" is not set at all!
I have a PreferenceActivity where I represent a setting UI, when I press the first checkbox then the second checkbox becomes visible. On the other hand, when the first checkbox is unchecked the second checkbox is hidden(and gets a default value to false).
The problem is that I need my UI screen to be refreshed the moment I check(or uncheck) the first checkbox because right now with that code I need to go to another Activity (e.g when I press the back button) and then get back to the PreferenceActivity again in order to see the changes on my UI.
Code for PreferenceActivity:
public class SetPreference extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.checkboxpref);
}
#Override
protected void onStart() {
super.onStart();
Preference checkbox = findPreference("checkBox_Schedule");
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(this);
if (prefs.getBoolean("checkBox", true)) {
} else {
((PreferenceGroup) findPreference("category_second"))
.removePreference(checkbox);
SharedPreferences.Editor geted = prefs.edit();
geted.putBoolean("checkBox_Schedule", false);
geted.commit();
}
}
#Override
protected void onResume() {
super.onResume();
}
#Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
// TODO Auto-generated method stub
}
}
Code for XML:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
android:summary="Username and password information"
android:title="Login information" >
<EditTextPreference
android:key="username"
android:summary="Please enter your login username"
android:title="Username" />
<EditTextPreference
android:inputType="textPassword"
android:key="password"
android:summary="Enter your password"
android:title="Password" />
</PreferenceCategory>
<PreferenceCategory
android:summary="Username and password information"
android:title="Settings"
android:key="category_first" >
<CheckBoxPreference
android:key="checkBox"
android:summary="On/Off"
android:title="Keep me logged in" />
<ListPreference
android:entries="#array/listOptions"
android:entryValues="#array/listValues"
android:key="listpref"
android:summary="List preference example"
android:title="List preference" />
</PreferenceCategory>
<PreferenceCategory
android:summary="schedule"
android:key="category_second"
android:title="Schedule" >
<CheckBoxPreference
android:key="checkBox_Schedule"
android:summary="On/Off"
android:title="Keep me logged in" />
</PreferenceCategory>
</PreferenceScreen>
Thank you for your time.
Ok then just restart the activity when the checkbox is selected/deselected:
startActivity(new Intent(PreferencesActivity.this, PreferencesActivity.class));
finish();
Consider using onPreferenceSelectedListener for the first checkbox to detect the act of checking/unchecking the preference.
I have a PreferenceScreen that has a PreferenceScreen within it. I am able to display a summary in my outer most PreferenceScreen on launch and also update the summaries onSharedPreferenceChanged, but my inner PreferenceScreen (in xml it has string #string/advanced) does not get the initial value...it does update onSharedPreferenceChanged. I need the intial to display as well. Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="main_pref">
<PreferenceCategory
android:title="#string/location_and_notifications">
<ListPreference
android:key="pref_temp_notifications"
android:title="#string/notifications"
android:entries="#array/pref_temp_notifications"
android:entryValues="#array/pref_temp_notifications_values"
android:dialogTitle="#string/notifications"
android:defaultValue="2"/>
<ListPreference
android:key="pref_notification_interval"
android:title="#string/notification_interval"
android:entries="#array/pref_notification_interval"
android:entryValues="#array/pref_notification_interval_values"
android:dialogTitle="#string/notification_interval"
android:defaultValue="15" />
<ListPreference
android:key="pref_open_at_launch"
android:title="#string/open_at_launch"
android:entries="#array/pref_open_at_launch"
android:entryValues="#array/pref_open_at_launch_values"
android:dialogTitle="#string/open_at_launch"
android:defaultValue="1"/>
<ListPreference
android:key="pref_push_notification"
android:title="#string/push_enabled"
android:entries="#array/pref_push_notification"
android:entryValues="#array/pref_push_notification_values"
android:dialogTitle="#string/push_enabled"
android:defaultValue="1"/>
</PreferenceCategory>
<PreferenceCategory
android:title="#string/units">
<ListPreference
android:key="pref_temp_units"
android:title="#string/temperature"
android:defaultValue="#string/default_metric"
android:entries="#array/pref_temp_units"
android:entryValues="#array/pref_temp_units_values"
android:dialogTitle="#string/units" />
<PreferenceScreen
android:title="#string/advanced"
android:key="advanced_pref">
<ListPreference
android:key="pref_speed"
android:title="#string/speed"
android:entries="#array/pref_speed"
android:entryValues="#array/pref_speed_values"
android:defaultValue="#string/default_metric"/>
<ListPreference
android:key="pref_measurement"
android:title="#string/measurement"
android:entries="#array/pref_measurement"
android:entryValues="#array/pref_measurement_values"
android:defaultValue="#string/default_metric"/>
<ListPreference
android:key="pref_time"
android:title="#string/time_format"
android:entries="#array/pref_time"
android:entryValues="#array/pref_time_values"
android:defaultValue="#string/default_metric"/>
<ListPreference
android:key="pref_date"
android:title="#string/date_format"
android:entries="#array/pref_date"
android:entryValues="#array/pref_date_values"
android:defaultValue="#string/default_metric"/>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:title="#string/personalization">
<ListPreference
android:key="pref_color_theme"
android:title="#string/color_theme"
android:entries="#array/pref_color_theme"
android:entryValues="#array/pref_color_theme_values"
android:dialogTitle="#string/color_theme"
android:defaultValue="-10981143" />
</PreferenceCategory>
<PreferenceCategory
android:title="#string/more">
<Preference
android:title="#string/platinum"
android:summary="#string/disable_ads"
android:key="upgradePref"/>
<Preference
android:title="#string/rate_update"
android:summary="#string/rate_app"
android:key="ratePref"/>
</PreferenceCategory>
<PreferenceCategory
android:title="#string/about">
<Preference
android:title="#string/eula"
android:summary=""
android:key="eulaPref"/>
<Preference
android:title="#string/privacy_policy"
android:summary=""
android:key="privacyPolicyPref"/>
<PreferenceScreen
android:title="#string/version"
android:summary=""
android:key="version">
</PreferenceScreen>
<PreferenceScreen
android:title="#string/customer_support"
android:summary="#string/email_us">
<intent android:action="com.accuweather.android.EMAIL_ACCUWX"
/>
</PreferenceScreen>
<PreferenceScreen
android:title="#string/accuweather_branding"
android:summary=""
android:key="accuweatherBranding">
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
Here is a code snippet:
in OnCreate I call this:
for(int i=0;i<getPreferenceScreen().getPreferenceCount();i++){
initSummary(getPreferenceScreen().getPreference(i));
}
private void initSummary(Preference p) {
if (p instanceof PreferenceCategory){
PreferenceCategory pCat = (PreferenceCategory)p;
for(int i=0;i<pCat.getPreferenceCount();i++){
initSummary(pCat.getPreference(i));
}
}else{
updatePrefSummary(p);
}
}
private void updatePrefSummary(Preference p) {
if (p instanceof ListPreference) {
ListPreference listPref = (ListPreference) p;
p.setSummary(listPref.getEntry());
}
}
Then in onSharedPreferenceChanged:
#Override
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
Log.i(DEBUG_TAG, "value of key is " + key);
Preference pref = findPreference(key);
...
updatePrefSummary(findPreference(key));
}
First, I have these constants in another class to reference:
public static final String PREF_TIME = "pref_time";
public static final String PREF_DATE = "pref_date";
public static final String PREF_SPEED = "pref_speed";
public static final String PREF_MEASUREMENT = "pref_measurement";
In order to get access to the embedded PreferenceScreen within the Preference Screen I do this:
// enable summary of one deep preferenceScreen
Preference advancedSpeedPref = (Preference) findPreference(ACCUWX.Preferences.PREF_SPEED);
ListPreference listPref1 = (ListPreference) advancedSpeedPref;
advancedSpeedPref.setSummary(listPref1.getEntry());
Preference advancedMeasurementPref = (Preference) findPreference(ACCUWX.Preferences.PREF_MEASUREMENT);
ListPreference listPref2 = (ListPreference) advancedMeasurementPref;
advancedMeasurementPref.setSummary(listPref2.getEntry());
Preference advancedTimeformatPref = (Preference) findPreference(ACCUWX.Preferences.PREF_TIME);
ListPreference listPref3 = (ListPreference) advancedTimeformatPref;
advancedTimeformatPref.setSummary(listPref3.getEntry());
Preference advancedDateformatPref = (Preference) findPreference(ACCUWX.Preferences.PREF_DATE);
ListPreference listPref4 = (ListPreference) advancedDateformatPref;
advancedDateformatPref.setSummary(listPref4.getEntry());
Works like a charm!