[英]Android toast on preference change
I want to tell the user that when he has changed one or more fields in the preference window that it was succesfully changed but I am running into some problems: 我想告诉用户,当他在首选项窗口中更改了一个或多个字段后,它已成功更改,但我遇到了一些问题:
listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
// Implementation
Toast.makeText(this,
"You have selected ",
Toast.LENGTH_SHORT).show();
}
};
appPrefs.registerOnSharedPreferenceChangeListener(listener);
however I get the following error: 但是我收到以下错误:
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new SharedPreferences.OnSharedPreferenceChangeListener(){}, String, int) Toast类型中的方法makeText(Context,CharSequence,int)不适用于参数(new SharedPreferences.OnSharedPreferenceChangeListener(){},String,int)
Can anyone tell me why I'm getting this? 有谁能告诉我为什么我得到这个?
Toast.makeText(ActivityName.this,
"You have selected ",
Toast.LENGTH_SHORT).show();
You should use activity context as the first parameter 您应该使用活动上下文作为第一个参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.