模仿Zaker加载框

来源:互联网 发布:linux查看所有服务 编辑:程序博客网 时间:2024/05/09 18:38


MyProgressDialog.java

package com.xzq.view;import android.app.Dialog;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.animation.AnimationUtils;import android.view.animation.RotateAnimation;import android.widget.ImageView;import android.widget.RelativeLayout;import com.xzq.zaker.R;/** * @author XZQ * @version */public class MyProgressDialog extends Dialog {    public Context context;// 上下文    public MyProgressDialog(Context context) {        super(context);        this.context = context;    }    public MyProgressDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {        super(context, cancelable, cancelListener);        this.context = context;    }    public MyProgressDialog(Context context, int theme) {        super(context, theme);        this.context = context;        View view = LayoutInflater.from(context).inflate(R.layout.load, null); // 加载自己定义的布局        ImageView img_loading = (ImageView) view.findViewById(R.id.img_load);        RelativeLayout img_close = (RelativeLayout) view.findViewById(R.id.img_cancel);        RotateAnimation rotateAnimation = (RotateAnimation) AnimationUtils.loadAnimation(context, R.anim.refresh); // 加载XML文件中定义的动画        img_loading.setAnimation(rotateAnimation);// 开始动画        setContentView(view);// 为Dialoge设置自己定义的布局        // 为close的那个文件添加事件        img_close.setOnClickListener(new View.OnClickListener() {            public void onClick(View v) {                dismiss();            }        });    }}




这就是那个自定义的核心类,代码:http://download.csdn.net/detail/cmdkmd/4631037


原创粉丝点击