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

  • 相关阅读:
    【数位dp】Beautiful Numbers @2018acm上海大都会赛J
    【状压dp】Trie 树 @中山纪念中学20170304
    两个给点染色的问题-树上染色与图上染色
    【贪心】经营与开发 @upc_exam_5500
    【二分+拓扑排序】Milking Order @USACO 2018 US Open Contest, Gold/upc_exam_6348
    【并查集】Connectivity @ABC049&amp;ARC065/upcexam6492
    【倍增】T-shirt @2018acm徐州邀请赛 I
    Sparse Coding: Autoencoder Interpretation
    Sparse Coding
    Pooling
  • 原文地址:https://www.cnblogs.com/honeynm/p/4287112.html
Copyright © 2011-2022 走看看