1. main文件

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >    <TextView        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/hello" />    <ProgressBar        android:id="@+id/progressBar1"        style="?android:attr/progressBarStyleHorizontal"        android:layout_width="255dp"        android:layout_height="wrap_content"        android:visibility="gone"         />    <ProgressBar        android:id="@+id/progressBar2"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:visibility="gone"         />    <Button         android:id="@+id/button"        android:text="Ok"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        /></LinearLayout>

2. java 文件的写法

package com.android.voew;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.ProgressBar;/** *  * @author liuqing * @version 1.0 * @see Android ProgreeBar 的使用 * 2011-10-12 * */public class Viewchapter3Activity extends Activity {    /** Called when the activity is first created. */private ProgressBar firstProgree;private ProgressBar secondProgree;private Button button;private int i = 0;    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        this.firstProgree = (ProgressBar)this.findViewById(R.id.progressBar1);        this.secondProgree = (ProgressBar)this.findViewById(R.id.progressBar2);        this.button = (Button)this.findViewById(R.id.button);        this.button.setOnClickListener(new ButtonListener());    }        //添加OnClickListener方法    class ButtonListener implements OnClickListener {@Overridepublic void onClick(View v) {if (i == 0) {firstProgree.setMax(150);secondProgree.setMax(150);firstProgree.setVisibility(View.VISIBLE);secondProgree.setVisibility(View.VISIBLE);button.setText("Begin");i++;}else {firstProgree.setProgress(i * 10);//设进度条的从进度属性firstProgree.setSecondaryProgress((i * 10) + 10);secondProgree.setProgress(i * 10);if (firstProgree.getMax() <= i * 10) {firstProgree.setVisibility(View.GONE);i = 0;button.setText("OK");secondProgree.setVisibility(View.GONE);}i++;}}        }}

更多相关文章

  1. android getResources的作用
  2. Android(安卓)文件的保存与读取之SDCard(SD卡)存储
  3. Android(安卓)DEV : setOnClickListener() vs. android:onClick
  4. 获取apk信息工具(android SDK的aapt工具)
  5. 开发可统计单词个数的Android驱动程序(1)
  6. Android(安卓)Layout布局文件里的android:layout_height等属性为
  7. Android(安卓)Studio 导入so
  8. Android(安卓)修改开机动画(bootanimation)
  9. android中下载文件到sdcard和进度条小结

随机推荐

  1. 目前Android最全面、最易懂的Android屏幕
  2. 移植 android, touch screen 不能正常工
  3. Android开发都需要使用什么语言?
  4. FFmpeg打造Android万能音频播放器-杨万里
  5. Android之——自定义TextView
  6. android 开发
  7. Android(安卓)为什么使用DVM虚拟机,而不使
  8. 10个android开源项目
  9. Weex 04 Weex中Android项目的生成和交互
  10. Android必备:Activity 活动 和 Intent 意