`
lxr215
  • 浏览: 58976 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

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();
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics