07 ProgressDialog

<span style="font-size:18px;">package com.fmy.example1;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends Activity {

    private ProgressDialog pro;

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

    public  void click(View v){
        switch (v.getId()) {
        case R.id.first:
            //创建一个progressDialog 传入上下文
            pro = new ProgressDialog(this);
            //设置标题
            pro.setTitle("下载");
            //设置图片
            pro.setIcon(R.drawable.ic_launcher);
            //设置样式 这是有水平条的
            pro.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            pro.show();
            break;
        case R.id.second:
            pro = new ProgressDialog(this);
            pro.setTitle("下载");
            pro.setIcon(R.drawable.ic_launcher);
            //一个转圈的进图条默认<span style="display: none; width: 0px; height: 0px;" id="transmark"></span>
            pro.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            pro.show();
            break;

        default:
            break;
        }
    }
}

</span>


posted on 2016-08-30 20:25  木鱼哥  阅读(81)  评论(0编辑  收藏  举报

导航