• 初识别进度条


    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)));
        }
    

      

  • 相关阅读:
    01 变量、基本数据类型
    02 gitlab的基本使用
    kubernetes
    02 redis高可用集群
    Redis & ELK
    01 Redis安装、配置详解、数据备份与恢复
    Jenkins
    01 git gitlab jenkins的安装
    golang mysql 客户端
    接口类
  • 原文地址:https://www.cnblogs.com/zmaibbs7/p/4843535.html
Copyright © 2020-2023  润新知