自定义的ProgressDialog show后怎么dismiss掉

Android 码拜 7年前 (2017-04-27) 1174次浏览
使用

ProgressDialogAnim.createLoadingDialog(
					AskFragment.this.getActivity(), "加载中……").show();

是在异步任务里面的,想在里onPreExecute方法里show然后在onPostExecute里dismiss,咋办啊求高手自定义的ProgressDialog show后怎么dismiss掉

import com.askme.app.R;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class ProgressDialogAnim {
	/**
	 * 得到自定义的progressDialog
	 * 
	 * @param context
	 * @param msg加载信息
	 * @return
	 */
	public static Dialog createLoadingDialog(Context context, String msg) {
		LayoutInflater inflater = LayoutInflater.from(context);
		View v = inflater.inflate(R.layout.loading_dialog, null);// 得到加载view
		LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view);// 加载布局
		// main.xml中的ImageView
		ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
		TextView tipTextView = (TextView) v.findViewById(R.id.tipTextView);// 提示文字
		// 加载动画
		Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(
				context, R.anim.loading_animation);
		// 使用ImageView显示动画
		spaceshipImage.startAnimation(hyperspaceJumpAnimation);
		tipTextView.setText(msg);// 设置加载信息
		Dialog loadingDialog = new Dialog(context, R.style.loading_dialog);// 创建自定义样式dialog
		loadingDialog.setCancelable(false);// 不可以用“返回键”取消
		loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.FILL_PARENT));// 设置布局
		return loadingDialog;
	}
}
解决方案

40

你这是自问自答吗!

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明自定义的ProgressDialog show后怎么dismiss掉
喜欢 (0)
[1034331897@qq.com]
分享 (0)