Android 提供ProgressDialog,可以提示进度,但你也可以自己实现,示例如下:

Java 代码
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_gravity="center_vertical"android:layout_width="fill_parent"
  4. android:layout_height="wrap_content">
  5. <ProgressBarandroid:layout_width="wrap_content"
  6. android:layout_height="wrap_content"android:id="@+id/progressbar_default"
  7. android:scaleType="fitCenter"android:layout_alignParentLeft="true"
  8. android:layout_margin="5dip"/>
  9. <ProgressBarandroid:layout_width="fill_parent"
  10. android:layout_height="wrap_content"style="?android:attr/progressBarStyleHorizontal"
  11. android:id="@+id/progressbar_Horizontal"android:max="100"
  12. android:layout_toRightOf="@id/progressbar_default"
  13. android:layout_margin="5dip"/>
  14. <TextViewandroid:layout_width="fill_parent"
  15. android:layout_height="wrap_content"android:id="@+id/progressbar_text"
  16. android:layout_toRightOf="@id/progressbar_default"android:paddingTop="25dip"
  17. android:layout_margin="5dip"android:text="inittext"/>
  18. </RelativeLayout>

Java代码
  1. publicclassClearProgressDialogextendsAlertDialogimplements
  2. DialogInterface.OnClickListener{
  3. privateProgressBarprogressBar;
  4. privateintprogress=0;
  5. protectedClearProgressDialog(Contextcontext){
  6. super(context);
  7. init();
  8. }
  9. publicClearProgressDialog(Contextcontext,booleancancelable,
  10. OnCancelListenercancelListener){
  11. super(context,cancelable,cancelListener);
  12. init();
  13. }
  14. publicClearProgressDialog(Contextcontext,inttheme){
  15. super(context,theme);
  16. init();
  17. }
  18. publicvoidinit(){
  19. Viewview=getLayoutInflater().inflate(R.layout.progresslayout,
  20. null);
  21. progressBar=(ProgressBar)view.findViewById(R.id.progressbar_Horizontal);
  22. setButton(getContext().getText(R.string.stop),this);
  23. setIcon(R.drawable.andclear);
  24. setTitle(R.string.clear_progress);
  25. setView(view);
  26. //progressBar=(ProgressBar)findViewById(R.id.progressbar_Horizontal);
  27. }
  28. publicvoidonClick(DialogInterfacedialog,intwhich){
  29. }
  30. HandlerpHandle=newHandler(){
  31. publicvoidhandleMessage(Messagemsg){
  32. }
  33. };
  34. publicvoidsetProgress(intper,Stringstr){
  35. }
  36. publicvoidstop(){
  37. }
  38. }

更多相关文章

  1. android计时demo源代码
  2. Android加载中动画
  3. Android写文件到SDCard的一般过程和代码
  4. android 代码混淆问题解决
  5. Android中如何修改CheckBox的颜色
  6. 指定Toast显示时长
  7. Android最好看的圆形进度条ProgressBar
  8. Android(安卓)小代码集
  9. 多线程实现更新android进度条。

随机推荐

  1. 用Python生成自己专属的手机春节壁纸
  2. super(props) 真的那么重要吗?[每日前端夜
  3. 推荐一个基于 Node.js 的表单验证库 [每
  4. CSS粘性定位是怎样工作的 [每日前端夜话0
  5. python格式化输出:%s和format()用法比较
  6. 对比MySQL学习Pandas的groupby分组聚合
  7. 教你用Python拆分表格并发送邮件
  8. 实战!半小时写一个脑力小游戏 [每日前端夜
  9. 干货!python与MySQL数据库的交互实战
  10. 用python数据分析了北京积分落户名单,发现