android progress bar的小实例

来源:互联网 发布:js onclick 参数 编辑:程序博客网 时间:2024/05/18 02:03

在MainActivity中描述一个按钮控件,编写单击事件,跳转到另一个ProgressBarActivity,ProgressBarActivity中开始使用进度条小例子:

在layout文件夹中创建progress_bar.xml的布局管理文件,同时在 AndroidManifest.xml中进行页面注册。

在progress_bar.xml中编写代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="图形进度条"
     />
    <ProgressBar
     android:id="@+id/progress_bar"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     />
     
    <TextView
      android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="水平进度条"
     />
    <ProgressBar
     android:id="@+id/progress_horizontal"
     style="?android:attr/progressBarStyleHorizontal"
     android:layout_height="wrap_content"
     android:layout_width="200dip"
     android:max="100"
     android:progress="50"
     android:secondaryProgress="75"
     />
</LinearLayout>

 

在ProgressBarActivity中将Activity与描述文件关联起来。

运行后可以看到初步的结果。