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 = {"张飞","刘备","关羽"};
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。