0

当使用此代码单击首选项时,我正在尝试打开 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;
            }
        });

    }

}

但是,当我单击首选项时,应用程序将关闭。有什么建议么?

4

0 回答 0