开发者

findpreference undefined type

开发者 https://www.devze.com 2023-04-08 12:59 出处:网络
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(){}

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开发者_如何学JAVA 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号