Dialogs

ProgressDialog:
	android.app.ProgressDialog;
	ProgressDialog dialog = ProgressDialog.show(MyActivity.this, "", 
                        "Loading. Please wait...", true);
	ProgressDialog必须在后台程序运行完毕前, 以dimmiss()方法来关闭取得焦点的对话框.

AlertDialog:
	android.app.AlertDialog;

	final CharSequence[] items = {"Red", "Green", "Blue"};
	AlertDialog.Builder builder = new AlertDialog.Builder(this);
	builder.setTitle("Pick a color");

	// 1.
	builder.setItems(items, new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int item) {
			Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
		}
	});
	
	// 2.
	builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int item) {
			Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
		}
	});

	// 3.
	builder.setMultiChoiceItems();

	AlertDialog alert = builder.create();
 

你可能感兴趣的:(android)