package com.pro;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.SpannableString;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
public class ProgressDialog1 extends AlertDialog {
public static final int STYLE_SPINNER = 0;
/** Creates a ProgressDialog1 with a horizontal progress bar.
*/
public static final int STYLE_HORIZONTAL = 1;
public static final int STYLE_DISMISS = -1;
private ProgressBar mProgress_h;
private int mProgressStyle = STYLE_SPINNER;
private TextView mProgressNumber_s,message_tv,message_ed_tv,message_center_tv,message_all_tv;
private int mMax;
private int mProgressVal;
private int mSecondaryProgressVal;
private int mIncrementBy;
private int mIncrementSecondaryBy;
private Drawable mProgressDrawable;
private Drawable mIndeterminateDrawable;
private CharSequence mMessage = "";
private boolean mIndeterminate;
private boolean mHasStarted;
private Handler mViewUpdateHandler;
private Context mContext;
private LinearLayout layout,layout_h,layout_s,layout_message_h;
private LinearLayout layout_progress_h,layout_progress_s;
private TextView message_h,number_ed,number_cen,number_all,progress_number2;
private ProgressBar progress_h,progress;
private SpannableString tmp;
public SpannableString getTmp() {
return tmp;
}
public void setTmp(SpannableString tmp) {
this.tmp = tmp;
}
public ProgressDialog1(Context context) {
this(context, android.R.style.Theme_Panel);
mContext = context;
}
public ProgressDialog1(Context context, int theme) {
super(context, theme);
}
public static ProgressDialog1 show(Context context, CharSequence title,
CharSequence message) {
return show(context, title, message, false);
}
public static ProgressDialog1 show(Context context, CharSequence title,
CharSequence message, boolean indeterminate) {
return show(context, title, message, indeterminate, false, null);
}
public static ProgressDialog1 show(Context context, CharSequence title,
CharSequence message, boolean indeterminate, boolean cancelable) {
return show(context, title, message, indeterminate, cancelable, null);
}
public static ProgressDialog1 show(Context context, CharSequence title,
CharSequence message, boolean indeterminate,
boolean cancelable, OnCancelListener cancelListener) {
ProgressDialog1 dialog = new ProgressDialog1(context);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setIndeterminate(indeterminate);
dialog.setCancelable(cancelable);
dialog.setOnCancelListener(cancelListener);
dialog.show();
return dialog;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if (mProgressStyle == STYLE_HORIZONTAL)
{
/* Use a separate handler to update the text views as they
* must be updated on the same thread that created them.
*/
mViewUpdateHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
/* Update the number and percent */
int progress = mProgress_h.getProgress();
int max = mProgress_h.getMax();
message_tv.setText(getMessage());
message_ed_tv.setText(""+progress);
message_all_tv.setText(""+max);
}
};
View view = initLayout();
layout_progress_h = layout_h;
layout_progress_s = layout_s;
layout_progress_s.setVisibility(View.GONE);
mProgress_h = progress_h;
mProgressNumber_s = progress_number2;
message_tv = message_h;
message_ed_tv = number_ed;
message_center_tv = number_cen;
message_all_tv = number_all;
message_center_tv.setText("/");
setView(view);
}
if (mMax > 0) {
setMax(mMax);
}
if (mProgressVal > 0) {
setProgress(mProgressVal);
}
if (mSecondaryProgressVal > 0) {
setSecondaryProgress(mSecondaryProgressVal);
}
if (mIncrementBy > 0) {
incrementProgressBy(mIncrementBy);
}
if (mIncrementSecondaryBy > 0) {
incrementSecondaryProgressBy(mIncrementSecondaryBy);
}
if (mProgressDrawable != null) {
setProgressDrawable(mProgressDrawable);
}
if (mIndeterminateDrawable != null) {
setIndeterminateDrawable(mIndeterminateDrawable);
}
if (mMessage != null) {
setMessage(mMessage);
}
setIndeterminate(mIndeterminate);
onProgressChanged();
super.onCreate(savedInstanceState);
}
@Override
public void onStart() {
super.onStart();
mHasStarted = true;
}
@Override
protected void onStop() {
super.onStop();
mHasStarted = false;
}
public void setProgress(int value) {
if (mHasStarted) {
mProgress_h.setProgress(value);
onProgressChanged();
} else {
mProgressVal = value;
}
}
public void setSecondaryProgress(int secondaryProgress) {
if (mProgress_h != null) {
mProgress_h.setSecondaryProgress(secondaryProgress);
onProgressChanged();
} else {
mSecondaryProgressVal = secondaryProgress;
}
}
public int getProgress() {
if (mProgress_h != null) {
return mProgress_h.getProgress();
}
return mProgressVal;
}
public int getSecondaryProgress() {
if (mProgress_h != null) {
return mProgress_h.getSecondaryProgress();
}
return mSecondaryProgressVal;
}
public int getMax() {
if (mProgress_h != null) {
return mProgress_h.getMax();
}
return mMax;
}
public void setMax(int max) {
if (mProgress_h != null) {
mProgress_h.setMax(max);
onProgressChanged();
} else {
mMax = max;
}
}
public void incrementProgressBy(int diff) {
if (mProgress_h != null) {
mProgress_h.incrementProgressBy(diff);
onProgressChanged();
} else {
mIncrementBy += diff;
}
}
public void incrementSecondaryProgressBy(int diff) {
if (mProgress_h != null) {
mProgress_h.incrementSecondaryProgressBy(diff);
onProgressChanged();
} else {
mIncrementSecondaryBy += diff;
}
}
public void setProgressDrawable(Drawable d) {
if (mProgress_h != null) {
mProgress_h.setProgressDrawable(d);
} else {
mProgressDrawable = d;
}
}
public void setIndeterminateDrawable(Drawable d) {
if (mProgress_h != null) {
mProgress_h.setIndeterminateDrawable(d);
} else {
mIndeterminateDrawable = d;
}
}
public void setIndeterminate(b
没有合适的资源?快使用搜索试试~ 我知道了~
android 进度条对话框例子
共42个文件
class:13个
png:12个
xml:6个
5星 · 超过95%的资源 需积分: 23 10 下载量 191 浏览量
2012-11-24
12:05:20
上传
评论
收藏 90KB ZIP 举报
温馨提示
1.在ProgressDialog的源码里可以明显的看到,在STYLE_HORIZONTAL和STYLE_SPINNER分别显示的是不同的XML,这就意味着你的进度条要么是转圈,要么是条形的。 2.不管是上述的任何情况下,系统对各部分文字显示都已经完全格式化。
资源推荐
资源详情
资源评论
收起资源包目录
ProgressDialog.zip (42个子文件)
ProgressDialog
bin
classes.dex 14KB
res
drawable-ldpi
icon.png 2KB
drawable-hdpi
icon.png 4KB
drawable
progressbar_indeterminate2.png 665B
progressbar_indeterminate3.png 656B
progressbar_indeterminate1.png 656B
drawable-mdpi
icon.png 2KB
TestProgress11111.apk 25KB
classes
com
pro
ProgressDia.class 2KB
R$layout.class 406B
ProgressDialog1$1.class 1KB
R$id.class 747B
R$drawable.class 617B
BeanUtils.class 2KB
R$attr.class 307B
ProgressDia$2.class 981B
ProgressDia$1.class 1KB
R.class 454B
ProgressDia$3.class 991B
R$string.class 394B
ProgressDialog1.class 9KB
resources.ap_ 17KB
res
drawable-ldpi
icon.png 2KB
drawable-hdpi
icon.png 4KB
drawable
progressbar_indeterminate2.png 775B
progress_indeterminate_horizontal.xml 1KB
progress_horizontal.xml 2KB
progressbar_indeterminate3.png 779B
progressbar_indeterminate1.png 779B
values
strings.xml 170B
drawable-mdpi
icon.png 3KB
layout
alert_dialog_progress.xml 2KB
main.xml 675B
assets
gen
com
pro
R.java 2KB
.settings
org.eclipse.jdt.core.prefs 629B
src
com
pro
ProgressDia.java 4KB
BeanUtils.java 1KB
ProgressDialog1.java 13KB
.project 853B
.classpath 304B
project.properties 445B
AndroidManifest.xml 631B
共 42 条
- 1
资源评论
- ceso1242013-09-09例子不错,学习了
- 25640636222013-09-09例子不错,学习了
- 安droid2013-10-10不错,很有价值!学习了!
- orangexiao20002015-06-07例子不错,学习了
CodeArtisanX
- 粉丝: 382
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功