我正在尝试使用此代码单击首选项时打开AlertDialog:
public class Opciones extends PreferenceActivity {
private Context ctx;
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.opciones);
Preference myPref = (Preference) findPreference("sobreApp");
myPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
builder.setCancelable(true);
builder.setTitle(R.string.sobreApp);
builder.setMessage(R.string.sobrePokeDroidex);
builder.show();
return false;
}
});
}
}
但是当我点击prefence应用程序关闭时。有什么建议吗?