这是我的偏好类:
customPref
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
Toast.makeText(getBaseContext(),
"The custom preference has been clicked",
Toast.LENGTH_LONG).show();
SharedPreferences customSharedPreference = getSharedPreferences(
"myCustomSharedPrefs", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = customSharedPreference
.edit();
editor.putString("myCustomPref",
"The preference has been clicked");
editor.commit();
return true;
}
});
这能够在 Toast 上显示数据。
但是当我应用此代码时
customPref
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
Intent int1 = new Intent(getBaseContext(),
termandcondition.class);
getBaseContext().startActivity(int1);
return true;
}
});
在首选项中,它变成了错误,现在显示数据请帮助我如何申请去另一个活动
这是 prefnces.xml 文件
<Preference
android:key="customPref"
android:summary="END-USER LICENCE AGREEMENT FOR USING WWW.TAXMANN.COM"
android:title="Term and Condition"
/>
我尝试了很多次现在能够做到请帮助我