سؤال

I am trying to set a value to a ListPreference and always get the error message:

The method findPreference(String) is undefined for the type new DialogInterface.OnClickListener(){}

This is my code:

ListPreference lp = (ListPreference) findPreference("enableTranslations");
lp.setValue("");

Thanks

هل كانت مفيدة؟

المحلول

You simply call findPreference in wrong place (in OnClickListener).

Call it in method of class that has findPreference method (PreferenceManager or PreferenceActivity) or on object of such type.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top