zoukankan      html  css  js  c++  java
  • Android入门之进度条(ProgressBar)

    package com.jkxqj.helloandroid;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.ProgressBar;
    
    public class MainActivity extends Activity {
    
    	private ProgressBar progressBar;
    	private Button firstButton;
    	private Button secondButton;
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);		
    		progressBar = (ProgressBar)findViewById(R.id.firstProgressBar);
    		firstButton = (Button)findViewById(R.id.firstButton);
    		secondButton = (Button)findViewById(R.id.secondButton);		
    		progressBar.setMax(100);		
    		firstButton.setOnClickListener(new FirstListener());
    		secondButton.setOnClickListener(new SecondListener());	
    	}	
    	class FirstListener implements OnClickListener{
    
    		@Override
    		public void onClick(View v) {
    			progressBar.incrementProgressBy(10);
    		}		
    	}	
    	class SecondListener implements OnClickListener{
    		@Override
    		public void onClick(View v) {
    			progressBar.incrementSecondaryProgressBy(20);
    		}
    	}
    	@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;
    	}
    
    }
    
    <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=".MainActivity" >
    
        <Button
            android:id="@+id/secondButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/firstProgressBar"
            android:layout_below="@+id/firstButton"
            android:layout_marginTop="26dp"
            android:text="增加第二进度" />
    
        <Button
            android:id="@+id/firstButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/secondButton"
            android:layout_below="@+id/firstProgressBar"
            android:layout_marginTop="17dp"
            android:text="增加第一进度" />
    
        <ProgressBar
            android:id="@+id/firstProgressBar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="30dp" />
    
    </RelativeLayout>


  • 相关阅读:
    Java作业一 (2017-9-10)
    遇到的坑1:传奇SF找不到背包数组
    黑白逆向编程课程笔记 18.局部&全局变量&参数详解
    黑白逆向编程课程笔记 16.浮点指令
    黑白逆向编程课程笔记 13.堆栈
    黑白逆向编程课程笔记 11.寄存器&补充
    SVN的trunk branches tags(一)
    JBoss Resteasy是一个遵守JAX-RS 标准的REST的开源项目
    JBOSS是sun公司的应用程序服务器,就象weblogic,jboss包含tomcat的所有功能.
    软件架构(体系结构,Architecture)和软件框架
  • 原文地址:https://www.cnblogs.com/bbsno1/p/3279859.html
Copyright © 2011-2022 走看看