I want to apply InputFilter to my EditTextPreferences...
Before I used the PreferenceActivity I had EditTexts with Filters like that:
et1 = (EditText) findViewById(R.id.editText1);
et2 = (EditText) findViewById(R.id.ETminsim);
et3 = (EditText) findViewById(R.id.ETdelay);
et1.setText(Integer.toString(PlotView.playlist_size), EditText.BufferType.EDITABLE);
et2.setText(Integer.toString(conversorToInt(PlotView.min_sim)), EditText.BufferType.EDITABLE);
et3.setText(Integer.toString(MusicService.getSeek()/1000), EditText.BufferType.EDITABLE);
et1.setFilters(new InputFilter[]{ new InputFilterMinMax(1, 30)});
et2.setFilters(new InputFilter[]{ new InputFilterMinMax(0, 100)});
et3.setFilters(new InputFilter[]{ new InputFilterMinMax(0, 300)});
But how can I reference to the EditTexts of the EditTextPreference in order to set these Filters?
My new Code:
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName(Singleton.PREFS_NAME);
addPreferencesFromResource(R.xml.prefs);
//TODO set InputFilter
}
Konstantin had it mostly correct. Combine his answer with Sebastian's comment on his answer and you get
EditText editText1 = ((EditTextPreference) findPreference(preference_1_key))
.getEditText();
editText1.setFilters(new InputFilter[]{ new InputFilterMinMax(1, 30) });