Re: [android-developers] Widget-specific Preferences
Jake,
It's possible to make your subclass of PreferenceActivity use a specific
preference file by putting something like this inside its onCreate:
PreferenceManager prefManager = getPreferenceManager();
prefManager.setSharedPreferencesName("widget_pref_" +
String.valueOf(widgetId));
This seems somewhat inefficient though, because each widget will get its
own preference storage file.
To use a single preference file where each widget gets its own set of
keys (dependent on a particular widget id), you could try using
Preference.setKey:
for preference : all Preferences in the screen {
String keyOriginal = preference.getKey();
String keyWithWidgetId = keyOriginal + String.valueOf(widgetId);
preference.setKey(keyWithWidgetId);
}
Hope this helps.
-- Kostya
24.04.2011 17:28, Jake Colman пишет:
> I currently use a Preference Activity and a preference XML file to
> manage my preferences. Since a Preference Activity handles edits on its
> own, is there still a way to use it if I need to change the key name at
> runtime to have a widget id? I am pretty sure I can get the widget from
> the intent since it is launched as a configuration activity but can I
> tap in and use it?
--
Kostya Vasilyev -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home