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

  • 相关阅读:
    Lambda表达式、依赖倒置
    ASP.NET vNext 概述
    Uname
    RHEL4 i386下安装rdesktop【原创】
    Taxonomy of class loader problems encountered when using Jakarta Commons Logging(转)
    How to decompile class file in Java and Eclipse
    先有的资源,能看的速度看,不能看的,抽时间看。说不定那天就真的打不开了(转)
    Google App Engine 学习和实践
    【VBA研究】VBA通过HTTP协议实现邮件轨迹跟踪查询
    js正則表達式语法
  • 原文地址:https://www.cnblogs.com/honeynm/p/4287112.html
Copyright © 2011-2022 走看看