zoukankan      html  css  js  c++  java
  • Android ProgressBar实现加载进度条

    progressBar Android进度条组件。
     
    progressBar的关键属性:
         android:max="100"     最大显示进度条
         android:progress="500"     第一显示进度
         android:secondaryProgress="80"     第二显示进度
         android:indeterminate="true"     设置是否精确显示
     
     
    progressBar的关键方法:
         setProgress(int)     设置第一进度。
         setSecondaryProgress(int)     设置第二进度
         getProgress()     获取第一进度
         getSecondaryProgress()     获取第二进度 
         incrementProgressBy(int)     增加或减少第一进度
         incrementSecondaryProgressBy(int)      增加或减少第二进度
         getMax()    获取最大进度。
     
     
    progressBar显示风格:
                   不设置style为中环形进度条
            style="?android:attr/progressBarStyleLarge"     //大环进度条
            style= "?android:attr/progressBarStyleSmall"     //小环形进度条
            style= "?android:attr/progressBarStyleHorizontal"     //水平进度条
     
    progressBar分类
              精确显示进度和不可精确显示进度。
     
    标题栏上的progressBar
    @Override
            protected void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);
                  setContentView(R.layout. activity_main);
                   //启动窗口特征
                  requestWindowFeature(Window. FEATURE_PROGRESS);
                  requestWindowFeature(Window. FEATURE_INDETERMINATE_PROGRESS);
                   //显示两种进度条。
                  setProgressBarVisibility( true);
                  setProgressBarIndeterminateVisibility( true);
                  setProgress(600);     //设置带进度的进度条的刻度  最大进度值为常量10000
           }
     
    对话框形式的进度条
    @Override
            protected void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);
                  setContentView(R.layout. activity_main);
                   //新建progressDialog对象
                   progressDialog=new ProgressDialog(MainActivity.this);
                   //设置显示风格
                   progressDialog.setProgressStyle(progressDialog .STYLE_HORIZONTAL);
                   //设置标题
                   progressDialog.setTitle("" );
                   /*
                   * 设定关于捧欧冠热身赛Bar的一些属性
                   */
                   //设定最大进度
                   progressDialog.setMax(100);
                   //设定初始化已经增长的进度
                   progressDialog.incrementProgressBy(50);
                   //指定进度条是明确显示进度的
                   progressDialog.setIndeterminate(false);
                   //设定一个按钮
                   progressDialog.setButton(DialogInterface.BUTTON_POSITIVE,"确定 ", new DialogInterface.OnClickListener() {
                         
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                               Toast. makeText(MainActivity.this, "", Toast.LENGTH_LONG).show();
                         }
                  });
                  
                   //是否可以通过返回按钮退出对话框
                   progressDialog.setCancelable(true);
                   //显示progreDialog
                   progressDialog.show();
                  
           }
     
    stareblankly.cn
  • 相关阅读:
    nexus docker 私有镜像处理
    nexus 使用Raw Repositories 进行maven site 发布
    nexus && minio s3 存储私有镜像
    spring boot 使用spring.resources.static-locations 分离系统模版&&资源文件
    Tencent Server Web 安装试用
    docker could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
    Tencent Server Web(TSW) 腾讯开源的nodejs 基础设施
    Stream Processing 101: From SQL to Streaming SQL in 10 Minutes
    13 Stream Processing Patterns for building Streaming and Realtime Applications
    Siddhi cep java 集成简单使用
  • 原文地址:https://www.cnblogs.com/stareblankly/p/4829281.html
Copyright © 2011-2022 走看看