ボタンつきのダイアログ作成
よくあるものとしては
Yes/No Ok/Cancel
を選択するダイアログの表示に使われる
これは使用頻度が多く
ユーザー登録とかアプリの権限取得
ネットワーク接続など
いろんな使い道がある
ボタンつきダイアログ作成するには
AlertDialogを使うことでできる
ボタンつきダイアログの作成はJavaで行う
AlertDialog.Builder alertDlg = new AlertDialog.Builder(this);
//タイトル設定
alertDlg.setTitle("Dialog Title");
//本文設定
alertDlg.setMessage("本文");
//okボタンクリック時
alertDlg.setPositiveButton("OK",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
}
});
//キャンセルボタンクリック時
alertDlg.setNegativeButton("Cancel",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
}
});
alertDlg.create().show();
AlertDialog.Builderで
AlertDialogを生成し、タイトルやメッセージ、ボタンをセットしていく