来自 编程应用 2019-09-07 12:06 的文章
当前位置: 六合联盟网 > 编程应用 > 正文

Android AlertDialog和ProgressDialog

public class NewAlertDialog{ public AlertDialog.Builder builder; public AlertDialog alertDialog; public ProgressDialog progressDialog; private Context context; public NewAlertDialog(Conetxt context){ setContext; builder = new AlertDialog.Builder(context,R.style.xxx); } public void setContext(Context context){ this.context = context; } public void getContext(){ return context; } //创建带左右按钮的对话框 public void makeAlertDialog(String title ,String message,String leftButtonText,String rightButtonText,DialogInterface.OnClickListener enterListener,DialogInterface.OnClickListener cancleListener) builder.setTitle; .setMessage; .setPositiveButton(rightButtonText,enterListener) .setNegativeButton(leftButtonText,cancelListener) ; alertDialog=builder.show(); } //dialog呈现无标题列表 public void makeAlertDialogForListItem(String title,String items[],DialogInterface.OnClickListener listener){ builder.setTitle .setItems(items.listener) builder.create; } //dialog呈现EditText public void makeAlertDialogForTextView(String title ,View view,String leftButtonText,String rightButtonText,DialogInterface.OnClickListener enterListener,DialogInterface.OnClickListener cancleListener){ builder.setTitle .setView .setPositiveButton(rightButtonText,enterListener) .setNegativeButton(leftButtonText,cancleListener) alertDialog = builder.show(); } //创建只带中间按钮的对话框 public void makeNeutralAlertDialog(String title,String message,String buttonText,DialogInterface.OnclickListener enterListener){ builder.setTitle .setMessage .setPositiveButton(buttonText,enterListener) .create(); alertDialog = builder.show(); alertDialog.setCancleButton; alsetDialog.setCancledOnTouchOutSide;//点击非Dialog区域不会关闭对话框 } //创建带ProgressBar的可以按返回键取消的Dialog public void makeProgressDialog(String title,Stirng message,DialogInteerface.OnclickListener onKeyListener,boolean canClose){ progressDialog = ProgressDialog.show(context,title,message); progressDialog.setOnKeyListener(onKeyListener); progressDialog.setCancleable; progressDialog.setCancledOnTouchOutSide; progressDialog.show(); } ```

本文由六合联盟网发布于编程应用,转载请注明出处:Android AlertDialog和ProgressDialog

关键词: