zoukankan      html  css  js  c++  java
  • progressBar

    main.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".Main" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />

        <ProgressBar
            android:id="@+id/progressBar1"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textView1"
            android:layout_below="@+id/textView1"
            android:layout_marginTop="25dp"
            android:max="100"
            android:progress="40"
            android:secondaryProgress="75"
            />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/progressBar1"
            android:layout_below="@+id/progressBar1"
            android:layout_marginTop="53dp"
            android:text="inc" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/button1"
            android:layout_marginLeft="44dp"
            android:layout_toRightOf="@+id/button1"
            android:text="dec" />

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/button1"
            android:layout_below="@+id/button1"
            android:layout_marginTop="47dp"
            android:text="inc2" />

        <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/button3"
            android:layout_alignBottom="@+id/button3"
            android:layout_alignLeft="@+id/button2"
            android:text="dec2" />

    </RelativeLayout>

    Main.java

    package com.example.myprocessbar;

    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.view.View;
    import android.view.Window;
    import android.widget.Button;
    import android.widget.ProgressBar;

    public class Main extends Activity {
     
     ProgressBar progressBar;
     
     Button  btn1, btn2, btn3, btn4;
     
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     
      super.onCreate(savedInstanceState);
      
      // requestWindowFeature(Window.FEATURE_NO_TITLE);
      
      requestWindowFeature(Window.FEATURE_PROGRESS);
      
      setContentView(R.layout.main);
      
      setProgressBarVisibility(true);
      
      progressBar = (ProgressBar) findViewById(R.id.progressBar1);
      
      btn1 = (Button) findViewById(R.id.button1);
      
      btn2 = (Button) findViewById(R.id.button2);
      
      btn3 = (Button) findViewById(R.id.button3);
      
      btn4 = (Button) findViewById(R.id.button4);
      
      btn1.setOnClickListener(new View.OnClickListener() {
       
       @Override
       public void onClick(View v) {
       
        // TODO Auto-generated method stub
        progressBar.incrementProgressBy(1);
        
        progressBar.setProgress(progressBar
          .getProgress());
        
       }
      });
      
      btn2.setOnClickListener(new View.OnClickListener() {
       
       @Override
       public void onClick(View v) {
       
        // TODO Auto-generated method stub
        progressBar.incrementProgressBy(-1);
        
        progressBar.setProgress(progressBar
          .getProgress());
        
       }
      });
      
      btn3.setOnClickListener(new View.OnClickListener() {
       
       @Override
       public void onClick(View v) {
       
        // TODO Auto-generated method stub
        progressBar.incrementSecondaryProgressBy(1);
        
        progressBar.setSecondaryProgress(progressBar
          .getSecondaryProgress());
        
       }
      });
      
      btn4.setOnClickListener(new View.OnClickListener() {
       
       @Override
       public void onClick(View v) {
       
        // TODO Auto-generated method stub
        progressBar.incrementSecondaryProgressBy(-1);
        
        progressBar.setSecondaryProgress(progressBar
          .getSecondaryProgress());
        
       }
      });
      
     }
     
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
     
      // Inflate the menu; this adds items to the action bar if it is
      // present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
     }
     
    }

  • 相关阅读:
    《ASP.NET Core项目开发实战入门》带你走进ASP.NET Core开发
    网络监控工具 iftop dstat
    可进行组合的枚举
    查看Qt自带的QSS
    通过文件设置QSS
    QString转QByteArray
    error: jump to case label
    error: static member function cannot have cv-qualifier
    C++ std::vector的大小和容量
    获取QMessageBox返回值
  • 原文地址:https://www.cnblogs.com/honeynm/p/4287112.html
Copyright © 2011-2022 走看看