标签:dialog 对话框
package com.example.util; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; public class SelectSupplyDialog { public static boolean isShow = false; public static Builder builder; public static Dialog dialog; public SelectSupplyDialog(){ } // 弹窗结果回调函数 public static abstract class ResultCallBack { public abstract void callback(int pos); } public static void showMyDialog(Context context, String title, String[] strArr, final ResultCallBack callback){ if(builder != null){ builder = null; } builder = new AlertDialog.Builder(context); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle(title); builder.setSingleChoiceItems(strArr, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface builder, int which) { isShow = false; builder.dismiss(); callback.callback(which); } } ); dialog = builder.show(); isShow = true; builder.setCancelable(true); } public static void closeDialog(){ if(dialog != null && isShow == true){ dialog.dismiss(); } } } /** * 扫描人选择 * @param v */ public void supply(View v){ SelectSupplyDialog.showMyDialog(mContext, "请选择供应商", strScanMan, new ResultCallBack() { @Override public void callback(int pos) { } }); } private String[] strScanMan = {"张飞","刘备","关羽"};
本文出自 “爬过山见过海” 博客,请务必保留此出处http://670176656.blog.51cto.com/4500575/1712532
标签:dialog 对话框
原文地址:http://670176656.blog.51cto.com/4500575/1712532