赞
踩
普通圆形ProgressBar
该类型进度条也就是一个表示运转的过程,例如发送短信,连接网络等等,表示一个过程正在执行中。
一般只要在XML布局中定义就可以了。
此时,没有设置它的风格,那么它就是圆形的,一直会旋转的进度条。
各大小样式圆形ProgressBar
超大号圆形ProgressBar
此时,给设置一个style风格属性后,该ProgressBar就有了一个风格,这里大号ProgressBar的风格是:
完整XML定义是:
小号圆形ProgressBar
小号ProgressBar对应的风格是:
标题型圆形ProgressBar
标题型ProgressBar对应的风格是:
完整XML定义是:
代码中实现:
长形进度条
布局中的长形进度条
①首先在XML进行布局
讲解:
②代码中运用
页面标题中的长形进度条
代码实现:
①先设置一下窗口风格特性
②然后设置进度值
ProgressDialog
ProgressDialog中的圆形进度条
ProgressDialog一般用来表示一个系统任务或是开启任务时候的进度,有一种稍等的意思。
代码实现:
ProgressDialog中的长形进度条
代码实现:
AlertDialog.Builder
AlertDialog中的圆形ProgressBar
①先来设计一个Layout,待会儿作为一个View,加入AlertDialog.Builder
②代码罗
AlertDialog中的长形ProgressBar(可控制)
①先来设计一个Layout,待会儿作为一个View,加入AlertDialog.Builder
②代码罗
③进度条进度值的按钮事件
Widget的实现就不再重复,假设您已经把Widget布局,相应设置已经设置好了。也可以在桌面加入类似上面图中的样式。
现在我们来实现一下按钮事件,与进度条的交互。
下面还是简单讲解一下Widget的设计与部署。
①设计Widget布局
②新增一个.res/xml目录,加入appwidget-provider
③实现一个AppWidgetProvider子类
④配置Manifest,进行注册
这里实现按钮与进度条的交互。(Widget自己广播发送与接收)
①按钮的消息发送
②Widget自身消息接收,使用intent.getAction()来获取Action
③进度条的进度值设置
注意了,Widget自身的onReceive()方法如果要接收其他的Action广播。那就必须在Manifest中,在Intent-filter中添加Action:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。