@Retention(value=CLASS) @Target(value={FIELD,METHOD,PARAMETER}) public @interface PreferenceByKey
Use it on a Preference or
Preference subtype or
android.support.v7.preference.Preference or
android.support.v7.preference.Preference subtype fields or methods with applicable parameters in a
EActivity or
EFragment annotated
class, which is a subclass of PreferenceActivity or PreferenceFragment(Compat), respectively.
The annotation value should be an array of R.string.* fields.
Your code related to injected preferences should go in an
AfterPreferences
annotated method.
Example :
@EActivity
public class SettingsActivity extends PreferenceActivity {
@PreferenceByKey(R.string.myPref1)
Preference myPreference1;
@PreferenceByKey(R.string.checkBoxPref)
CheckBoxPreference checkBoxPref;
@PreferenceByKey
void singleInjection(Preference myPreference1) {
// do stuff
}
void multiInjection(@PreferenceByKey Preference myPreference1, @PreferenceByKey(R.string.checkBoxPref) CheckBoxPreference checkBoxPref) {
// do stuff
}
@AfterPreferences
void initPrefs() {
checkBoxPref.setChecked(false);
}
}
AfterPreferencespublic abstract int value
public abstract String resName
Copyright © 2010–2016 simpligility technologies inc.. All rights reserved.