zoukankan      html  css  js  c++  java
  • android---------课外拓展Progress & ProgressDialog

    java代码

    package com.example.myapplication;
     
    import androidx.appcompat.app.AppCompatActivity;
     
    import android.app.Dialog;
    import android.app.ProgressDialog;
    import android.content.DialogInterface;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
     
    public class proActivity extends AppCompatActivity {
         private Button pro1,pro2;
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_pro);
            pro1=findViewById(R.id.pro1);
            pro2=findViewById(R.id.pro2);
            pro1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    ProgressDialog progressDialog=new ProgressDialog(proActivity.this);
                    progressDialog.setTitle("登陆中~~~");
                    progressDialog.setMessage("正在登陆");
                    progressDialog.setButton(DialogInterface.BUTTON_POSITIVE, "取消登陆", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            Toast.makeText(proActivity.this,"取消登陆",Toast.LENGTH_SHORT).show();
                        }
                    });
                    progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialogInterface) {
                            Toast.makeText(proActivity.this,"加载完成",Toast.LENGTH_SHORT).show();
                        }
                    });
                    progressDialog.show();
                }
            });
            pro2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    ProgressDialog progressDialog=new ProgressDialog(proActivity.this);
                    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                    progressDialog.setTitle("提示");
                    progressDialog.setMessage("正在下载...");
                    progressDialog.setButton(DialogInterface.BUTTON_POSITIVE, "继续下载", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
     
                        }
                    });
                    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "取消下载", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
     
                        }
                    });
                    progressDialog.show();
                }
            });
        }
    }
    

      XML代码

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="15dp"
        android:orientation="vertical"
        >
        <Button
            android:layout_marginTop="200dp"
            android:id="@+id/pro1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="progressBar练习"
            android:textAllCaps="false"
            />
     
        <Button
            android:layout_marginTop="200dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="progressDialog练习"
            android:textAllCaps="false"
            android:id="@+id/pro2"/>
     
    </LinearLayout>
    

      

     

     
     
  • 相关阅读:
    盲签名——典型的数字签名技术
    环签名——典型的数字签名技术
    多重签名——典型的数字签名技术
    历史多数攻击——共识攻击介绍
    看一篇,学一篇,今日份的pandas,你该这么学!No.2
    哈希算法
    什么是多重签名?多重签名的概念
    POJ 1023 The Fun Number System
    (四)Spring Boot之配置文件-多环境配置
    (四)Spring Boot之配置文件-多环境配置
  • 原文地址:https://www.cnblogs.com/xuwei123456/p/13972562.html
Copyright © 2011-2022 走看看