requestWindowFeature(Window.FEATURE_NO_TITLE);
この API は、画面に部品を配置する前、つまり「setContentView(int)」より前に実行しておきます。
でないと「AndroidRuntimeException: requestFeature() must be called before adding content」がスローされます。
メッセージ表示
AlertDialog.Builder dlg = new AlertDialog.Builder(this);
dlg.setIcon(R.drawable.icon);
dlg.setTitle("タイトル");
dlg.setMessage("メッセージ");
dlg.show();
AlertDialog.Builder dlg = new AlertDialog.Builder(this);
dlg.setIcon(R.drawable.icon);
dlg.setTitle("タイトル");
dlg.setMessage("メッセージ");
dlg.setPositiveButton("了解", null);
dlg.show();
AlertDialog.Builder dlg = new AlertDialog.Builder(this);
dlg.setIcon(R.drawable.icon);
dlg.setTitle("タイトル");
dlg.setMessage("メッセージ");
dlg.setPositiveButton("はい", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// 「はい」が押された時の処理
}
});
dlg.setNegativeButton("いいえ", null);
dlg.show();