专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 移动开发

自定义progressdialog加载动画,这边还有旋转的加载条,美团,多个图片动画

发布时间:2010-05-29 23:39:39 文章来源:www.iduyao.cn 采编人员:星星草
自定义progressdialog加载动画,这里还有旋转的加载条,美团,多个图片动画

自定义progressdialog加载动画,这里还有旋转的加载条,美团,多个图片动画

下载Demo:http://download.csdn.net/detail/menglele1314/8775497


public class MainActivity extends Activity {

    private Button submit;

    private AnimationDrawable fightnimation, fightnimationab;
    private ImageView pb, net, netab;
    private Dialog mLoading;
    private Animation animation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);

        submit = (Button) findViewById(R.id.btn_login_submit);
        
        pb = (ImageView) findViewById(R.id.iv_failure);
        animation = AnimationUtils.loadAnimation(MainActivity.this,
                R.anim.cirle);
        animation.setInterpolator(new LinearInterpolator());

        netab = (ImageView) findViewById(R.id.iv_netab);
        netab.setBackgroundResource(R.anim.fight);
        fightnimationab = (AnimationDrawable) netab.getBackground();

        net = (ImageView) findViewById(R.id.iv_net);
        net.setBackgroundResource(R.anim.loading);
        fightnimation = (AnimationDrawable) net.getBackground();

        submit.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                mLoading = createLoadingDialog(MainActivity.this);
                mLoading.show();
//                mLoading.dismiss();

                pb.startAnimation(animation);
                fightnimationab.start();
                fightnimation.start();

            }
        });
    }

    /**
     * 得到自定义的progressDialog
     *
     * @param context
     * @return
     */
    public static Dialog createLoadingDialog(Context context) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.layout_loading_dialog, null); // 得到加载view
        LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view); // 加载布局
        ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
        Animation animation = AnimationUtils.loadAnimation(
                context, R.anim.cirle); // 加载动画
        animation.setInterpolator(new LinearInterpolator());
        spaceshipImage.startAnimation(animation); // 使用ImageView显示动画
        Dialog loadingDialog = new Dialog(context, R.style.loading_dialog); // 创建自定义样式dialog

        // loadingDialog.setCancelable(false);// 不可以用"返回键"取消
        loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        return loadingDialog;
    }
}

下载Demo:点击打开链接

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: