Android ProgressBar简单使用

页面代码





    

后台Java代码

package com.example.lenovo.myapplication;

import android.app.ProgressDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast;

public class PBActivity extends AppCompatActivity implements View.OnClickListener{
ProgressBar pb;
Button bt1,bt2,bt3;
int nml;
final int Max=100;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pb);
        pb=findViewById(R.id.pb);
        bt1=findViewById(R.id.bt1);
        bt2=findViewById(R.id.bt2);
        bt3=findViewById(R.id.bt3);
        bt1.setOnClickListener(this);
        bt2.setOnClickListener(this);
        bt3.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
    switch (v.getId()){
        case R.id.bt1:
            final   ProgressDialog dialog=new ProgressDialog(this);
            dialog.setTitle("等待");
            dialog.setMessage("加载中...");
            dialog.setIcon(R.drawable.ic_launcher_background);
            dialog.show();

            break;
        case R.id.bt2:
            nml=0;
            if(nml

你可能感兴趣的:(Android)