How can I get a reference to my EditTextPreference in my main activity?
I have tried this:
EditTextPreference mEditTextPref =(EditTextPreference) findPreference(incrementby);
but its giving me this error;
incrementby cannot be resolved to a variable
This is the code for the EditTextPreference
android:defaultValue="1"
android:inputType="number"
android:key="incrementby"
android:maxLength="3"
android:summary="Set the incremental value of the counter"
android:title="Increase Count by" />
After getting a reference to the EditTextPreferece, what I want to do is, use this reference to set the value of the EditTextPreferece through my main activity. Something like;
mEditTextPref.setText("1");
the error says it: it is not a variable!! that is, the 'icrementby' is not a variable and expected a string! so enclose it in a double quotes ("incrementby").
EDIT
create a local variable in your activity:
and in the onCreate, do:
then use