Я сделал этот код. При каждом нажатии кнопки «ОК» в диалоговом окне происходит сбой приложения с указанным исключением. Я не могу понять, почему, любая помощь? Я следовал этим инструкциям из документации Android.
package com.grawl.faqplus;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class FAQPlusActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Set up buttons
Button buttonExit = (Button) findViewById(R.id.button_exit);
Button buttonAbout = (Button) findViewById(R.id.button_about);
// Set up AlertDialog for buttonAbout
String aboutMessage = (String) getString(R.string.dialog_about);
AlertDialog.Builder builderAbout = new AlertDialog.Builder(this);
builderAbout.setMessage(aboutMessage);
builderAbout.setCancelable(false);
builderAbout.setNeutralButton("OK!", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
final AlertDialog alertAbout = builderAbout.create();
// Show about dialog
buttonAbout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
alertAbout.show();
}
});
// Exit app
buttonExit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
System.exit(0);
}
});
}
}