弹出可选择对话框
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://scyanting.com/article/jphigs.html