You can subclass Preference by overriding onBindDialogView() - just remember to change the XML from <Preference...> to include your package and class <com.example.app.BadgedPreference...> :
@Override protected void onBindDialogView(View v) { super.onBindDialogView(v); Log.v( "onBindDialogView()", v.getClass().getSimpleName() ); }
If your BadgedPreference has a method for handling your changes, you can use it a little easier - from your PreferenceActivity :
PreferenceScreen myPrefScreen = (PreferenceScreen)getPreferenceScreen(); BadgedPreference bp = (BadgedPreference)myPrefScreen.findPreference("download_data");
More simply, you can use the standard Preference , simply compose its summary field as an βiconβ, then you can set the value using the Summary field:
Preference pref = (Preference)myPrefScreen.findPreference("download_data"); pref.setSummary("12");
Let me know if you have any questions.
CodeShane
source share