package com.alertDialogText;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.Toast;
public class AlertDialogText extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// ダイアログのオブジェクト(dlg) 生成
AlertDialog.Builder dlg = new AlertDialog.Builder(this);
// ダイアログにタイトルを指定
dlg.setTitle("タイトル");
// ダイアログにリストを指定
final CharSequence[] items = { "Red", "Green", "Blue" };
dlg.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item],
Toast.LENGTH_SHORT).show();
}
});
// ダイアログを表示
dlg.show();
}
}
setTitle(""); と同時には使えないみたいです。

0 件のコメント:
コメントを投稿