zoukankan      html  css  js  c++  java
  • 初识别进度条

    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            //启用窗口特征
            //进度条
    //        requestWindowFeature(Window.FEATURE_PROGRESS);
            //进度圈圈 表示状态 不能显示具体数值
           requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
            setContentView(R.layout.activity_main);
            //显示两种进度条
    
            //进度条可看见
           setProgressBarIndeterminateVisibility(true);
    
            //进度条 可看见 Max = 10000
            setProgressBarVisibility(true);
            setProgress(10000);
    
        }
    

      

    按钮控制

    public class MainActivity extends Activity implements View.OnClickListener{
        private ProgressBar progress;
        private Button add;
        private Button reduce;
        private Button reset;
        private TextView text;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            //注册控件
            init();
    
            add.setOnClickListener(this);
            reduce.setOnClickListener(this);
            reset.setOnClickListener(this);
        }
    
        private void init() {
            progress = (ProgressBar)findViewById(R.id.progressBar);
            add       = (Button) findViewById(R.id.button1);
            reduce   =  (Button) findViewById(R.id.button2);
            reset   =(Button)findViewById(R.id.button3);
            text    =(TextView)findViewById(R.id.textView);
    
            //获取进度
            int first =  progress.getProgress();
            int second=  progress.getSecondaryProgress();
            int Max   =  progress.getMax();
    
            text.setText("第一进度条百分比:" + ((int) (first / (float) Max * 100)) + "第二进度条百分比为:" + ((int) (second / (float) Max * 100)));
        }
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case  R.id.button1:
                    progress.incrementProgressBy(10);
                    progress.incrementSecondaryProgressBy(10);
                    break;
                case  R.id.button2:
                    progress.incrementProgressBy(-10);
                    progress.incrementSecondaryProgressBy(-10);
                    break;
                case  R.id.button3:
                    progress.setProgress(0);
                    progress.setSecondaryProgress(10);
                    break;
            }
            text.setText("第一进度条百分比:" + ((int) (progress.getProgress() / (float) progress.getMax() * 100)) + "第二进度条百分比为:" + ((int) (progress.getSecondaryProgress() / (float) progress.getMax() * 100)));
        }
    

      

  • 相关阅读:
    从零开始学SQLSERVER-游标CURSOR(基础)
    从零开始学SQLSERVER-创建表
    从零开始学HTML-button
    从零开始学前端HTML-input标签
    专项测试实战 | 如何测试 App 流畅度(基于 FPS 和丢帧率)
    接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
    软件测试之30分钟轻松搞定正则表达式基础
    Python 装饰器填坑指南 | 最常见的报错信息、原因和解决方案
    react16与react15之间的区别
    react-父子组件之间的交互传值
  • 原文地址:https://www.cnblogs.com/zmaibbs7/p/4843535.html
Copyright © 2011-2022 走看看