首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android 进度条的施用(转)

2012-07-05 
android 进度条的使用(转)????进度条的分类:一种是带数字,比如迅雷下载那种,还有一种一个圈转啊转啊。下面

android 进度条的使用(转)

?

?

?

?

进度条的分类:一种是带数字,比如迅雷下载那种,还有一种一个圈转啊转啊。

下面是代码:

?



android 进度条的施用(转)

该类型进度条也就是一个表示运转的过程,例如发送短信,连接网络等等,表示一个过程正在执行中。

一般只要在XML布局中定义就可以了。

此时,给设置一个style风格属性后,该ProgressBar就有了一个风格,这里大号ProgressBar的风格是:

小号ProgressBar对应的风格是:

android 进度条的施用(转)

标题型ProgressBar对应的风格是:<?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:gravity="center" android:orientation="vertical" > <SeekBar android:id="@+id/seekBar1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <ProgressBar android:id="@+id/progressBar1" style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" /></LinearLayout>?

?

--------------------------------------------

长形进度条

布局中的长形进度条

android 进度条的施用(转)

①首先在XML进行布局



②代码中运用

代码实现:
①先设置一下窗口风格特性

android 进度条的施用(转)

该类型进度条也就是一个表示运转的过程,例如发送短信,连接网络等等,表示一个过程正在执行中。

一般只要在XML布局中定义就可以了。

此时,给设置一个style风格属性后,该ProgressBar就有了一个风格,这里大号ProgressBar的风格是:

小号ProgressBar对应的风格是:

android 进度条的施用(转)

标题型ProgressBar对应的风格是:

    striver

    android 进度条的施用(转)android 进度条的施用(转)android 进度条的施用(转)



      ①首先在XML进行布局

      ②代码中运用

      代码实现:
      ①先设置一下窗口风格特性

      striver

      android 进度条的施用(转)android 进度条的施用(转)android 进度条的施用(转)



        android 进度条的施用(转)
        ??
        ProgressDialog一般用来表示一个系统任务或是开启任务时候的进度,有一种稍等的意思。
        代码实现:

        striver

        android 进度条的施用(转)android 进度条的施用(转)android 进度条的施用(转)



          android 进度条的施用(转)

          代码实现:

          striver

          android 进度条的施用(转)android 进度条的施用(转)android 进度条的施用(转)



            ①先来设计一个Layout,待会儿作为一个View,加入 AlertDialog.Builder
          • <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          • ? ? android:layout_gravity="center_horizontal"?
          • ? ? android:layout_width="wrap_content"
          • ? ? android:layout_height="wrap_content">
          • ? ? <LinearLayout android:id="@+id/LinearLayout01"
          • ? ? android:layout_width="wrap_content"?
          • ? ? android:layout_height="wrap_content">
          • </LinearLayout>
          • ? ? <ProgressBar android:layout_gravity="center_vertical|center_horizontal"
          • ? ? ? ? android:layout_height="wrap_content"?
          • ? ? ? ? android:progress="57"
          • ? ? ? ? android:id="@+id/myView_ProgressBar2"?
          • ? ? ? ? android:layout_width="wrap_content">
          • </ProgressBar>
          • </LinearLayout>
            复制代码②代码罗

            striver

            android 进度条的施用(转)android 进度条的施用(转)android 进度条的施用(转)



              ①先来设计一个Layout,待会儿作为一个View,加入AlertDialog.Builder
            • <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            • ? ? android:layout_gravity="center_horizontal"?
            • android:layout_width="wrap_content"
            • ? ? android:layout_height="wrap_content">
            • ? ? <Button?
            • android:layout_height="wrap_content"?
            • android:text="-"
            • ? ? ? ? android:layout_width="50dp"?
            • android:id="@+id/myView_BT_Down">
            • </Button>
            • ? ? <ProgressBar?
            • android:layout_gravity="center_vertical"
            • ? ? ? ? android:layout_height="wrap_content"?
            • style="?android:attr/progressBarStyleHorizontal"
            • ? ? ? ? android:id="@+id/myView_ProgressBar"?
            • android:progress="57"
            • ? ? ? ? android:layout_width="178dp">
            • </ProgressBar>
            • ? ? <Button android:layout_height="wrap_content"?
            • android:text="+"
            • ? ? ? ? android:layout_width="50dp"?
            • android:id="@+id/myView_BT_Up">
            • </Button>
            • </LinearLayout>
              复制代码②代码罗

              striver

              android 进度条的施用(转)android 进度条的施用(转)android 进度条的施用(转)



                Widget的实现就不再重复,假设您已经把Widget布局,相应设置已经设置好了。也可以在桌面加入类似上面图中的样式。

                现在我们来实现一下按钮事件,与进度条的交互。

                下面还是简单讲解一下Widget的设计与部署。

                ①设计Widget布局
              • <LinearLayout?
              • ? ? xmlns:android="http://schemas.android.com/apk/res/android"
              • ? ? android:background="@drawable/widget"?
              • ? ? android:layout_height="74dp"?
              • ? ? android:layout_width="296dp">
              • ? ? <Button?
              • ? ? ? ? android:layout_height="wrap_content"?
              • ? ? ? ? android:text="-"?
              • ? ? ? ? android:layout_gravity="center_vertical"
              • ? ? ? ? android:layout_width="50dp"?
              • ? ? ? ? android:id="@+id/widget_BT_Down"?
              • ? ? ? ? android:layout_marginLeft="10dp">
              • ? ? </Button>
              • ? ? <ProgressBar?
              • ? ? ? ? android:layout_gravity="center_vertical"
              • ? ? ? ? android:layout_height="wrap_content"?
              • ? ? ? ? style="?android:attr/progressBarStyleHorizontal"
              • ? ? ? ? android:layout_width="178dp"?
              • ? ? ? ? android:id="@+id/widget_ProgressBar">
              • ? </ProgressBar>
              • ? ? <Button?
              • ? ? ? ? android:layout_height="wrap_content"?
              • ? ? ? ? android:text="+"?
              • ? ? ? ? android:layout_gravity="center_vertical"
              • ? ? ? ? android:layout_width="50dp"?
              • ? ? ? ? android:id="@+id/widget_BT_Up">
              • ? </Button>
              • </LinearLayout>
                复制代码

                striver

                android 进度条的施用(转)android 进度条的施用(转)android 进度条的施用(转)

                • <appwidget-provider?
                • ? ? xmlns:android="http://schemas.android.com/apk/res/android"
                • ? ? android:initialLayout="@layout/widgetlayout"
                • ? ? android:updatePeriodMillis="8660000"?
                • ? ? android:minWidth="296dp"
                • ? ? android:minHeight="74dp">
                • </appwidget-provider>
                  复制代码③实现一个AppWidgetProvider子类

                  striver

                  android 进度条的施用(转)android 进度条的施用(转)android 进度条的施用(转)

                    1. <receiver android:name="AppWidget">
                    2. ? ? <intent-filter>
                    3. ? ? ? ? <action android:name="android.appwidget.action.APPWIDGET_UPDATE"></action>
                    4. ? ? ? ? ? ? ? ? <action android:name="zyf.test.widget.UP"></action>
                    5. ? ? ? ? ? ? ? ? <action android:name="zyf.test.widget.DOWN"></action>
                    6. ? ? </intent-filter>
                    7. ? ? <meta-data
                    8. ? ? ? ? android:resource="@xml/appwidget"
                    9. ? ? ? ? android:name="android.appwidget.provider">
                    10. ? ? </meta-data>
                    11. </receiver>
                    复制代码 1 楼 endual 2012-05-21   http://www.pin5i.com/showtopic-android-progressbar-sample.html

热点排行
Bad Request.