1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package com.topsoft.jianyu.util;
- import android.app.Dialog;
- import android.content.Context;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.widget.LinearLayout;
- import android.widget.RelativeLayout;
- import android.widget.TextView;
- import com.topsoft.jianyu.R;
- /**
- * Created by wanghuidong on 2017/12/25.
- */
- public class LoadingUtils {
- public static Dialog createLoadingDialog(Context context, String msg) {
- LayoutInflater inflater = LayoutInflater.from(context);
- View v = inflater.inflate(R.layout.simple_loading_view, null);// 得到加载view
- RelativeLayout layout = (RelativeLayout) v
- .findViewById(R.id.dialog_loading_view);// 加载布局
- TextView tipTextView = (TextView) v.findViewById(R.id.simple_loading_view_text);// 提示文字
- tipTextView.setText(msg);// 设置加载信息
- Dialog loadingDialog = new Dialog(context, R.style.simple_progress_dialog_three_style);// 创建自定义样式dialog
- loadingDialog.setCancelable(true); // 是否可以按“返回键”消失
- loadingDialog.setCanceledOnTouchOutside(false); // 点击加载框以外的区域
- loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));// 设置布局
- loadingDialog.show();
- return loadingDialog;
- }
- /**
- * 关闭dialog
- * <p>
- * http://blog.csdn.net/qq_21376985
- *
- * @param mDialogUtils
- */
- public static void closeDialog(Dialog mDialogUtils) {
- if (mDialogUtils != null && mDialogUtils.isShowing()) {
- mDialogUtils.dismiss();
- }
- }
- }
|