AlertDialogのメモ
前のエントリに引き続きAndroidの練習メモ.
主に使いそうなダイアログは5種類.
- AlertDialog
- DatePickerDialog
- ProgressDialog
- TimePickerDialog
- ZoomDialog
実際に使うときはメンバ変数としてインスタンスを用意する.
この変数は,ボタン等から呼び出せるようにfinal修飾子を付けておく.
サンプルで書いていないことはEclipseに助けられてるなぁ.
例)AlertDialog呼び出し
public class DialogSample extends Activity { (略) final AlertDialog.Builder alert = new AlertDialog.Builder(this); Button dialog_button = (Button)findViewById(R.id.dialog_button); dialog_button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { alert.show(); } }); } }