---
title: "对话框菜单"
author: "AndLi"
date: "2012-05-10T22:21:49Z"
tags: []
categories: ["移动开发"]
slug: "untitled"
draft: false
lastmod: "2012-05-18T14:22:16Z"
id: 1522468
url: "https://andli.iteye.com/blog/1522468"
---

```
	/**
	 * 
	 * @author lilin
	 * @date 2012-5-18 下午2:21:14
	 * @annotation 对话框菜单
	 */
	public static void showAlertMenu(Context con, String title,
			String menuitems[], DialogInterface.OnClickListener listener) {
		AlertDialog.Builder builder = new AlertDialog.Builder(con);
		builder.setTitle(title);
		builder.setItems(menuitems, listener);
		builder.setIcon(R.drawable.epoint2);
		AlertDialog alertDialog = builder.create();
		alertDialog.show();
	}
```

 

 

 

 

 

 

 

```
	/**
	 * 处理
	 */
	private void handleButtonClick() {
		Log.d("tracy", "handleButtonClick");
		String handleItems[] = { "抄牌上报", "非抄牌上报", /* "发送语音通知", */"查询历史信息" };
		System.out.print(handleItems);
		Log.d("tracy", "handleItems" + handleItems);
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle("处理");
		builder.setItems(handleItems, new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				switch (which) {
				case 0:
					// 抄牌上报
					clpReport("否");
					break;
				case 1:
					// 非抄牌上报
					clpReport("是");
					break;
				// case 2:
				// // 发送语音通知
				// sendYYTZ();
				// break;
				case 2:
					// 查询历史信息
					showCarHistoryInfo();
					break;
				default:
					break;
				}
			}
		});
		AlertDialog alertDialog = builder.create();
		alertDialog.show();
		Log.d("tracy", "alertDialog");
	}
```