ProgressDialog Number Format 을 android.app.ProgressDialog DEVICE_DAFAULT_LIGHT UI를 유지하면서
number format만 2.0MB / 4.0MB 형태로 표시 가능한 방법이 있을까요? (다이얼로그는 Service에서 띄워주고있음)
즉, new ProgressDialog(mContext, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
와 같은 UI를 가지되, NumberFormat만 2.0MB / 4.0MB 로 float+MB 형태로 표시가능한지 문의드립니다.
-------------------------------------------------------------------------------------------------------------------
※ 현재 문제점
Custom Dialog를 이용하면 앞으로 바뀔 테마에 대응하지 못하게되고, (AlertDailog 부분은 디바이스 테마에 맞게 바뀌지만, percent, number부분은 바뀌지 않음)
android.app.ProgressDialog를 이용하면 float형태로 보여주지 못하고있습니다. (2.0MB / 4.0MB 소숫점형태)
가이드 부탁드립니다.
-------------------------------------------------------------------------------------------------------------------
※참고: 현재까지 시도한 부분
1. CustomProgressDialog extends AlertDialog 정의후
onCreate에서
mViewUpdateHandler를 구현해 setText하기전 2.0MB / 4.0MB 형태로 바꿔서 적용
mViewUpdateHandler = new Handler() {
@Override
public void More ...handleMessage(Message msg) {
super.handleMessage(msg);
/* Update the number and percent */
int progress = mProgress.getProgress();
int max = mProgress.getMax();
if (mProgressNumberFormat != null) {
String format = mProgressNumberFormat;
mProgressNumber.setText(String.format(format, progress, max)); // 이부분 수정
} else {
mProgressNumber.setText("");
}
if (mProgressPercentFormat != null) {
double percent = (double) progress / (double) max;
SpannableString tmp = new SpannableString(mProgressPercentFormat.format(percent));
tmp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
0, tmp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mProgressPercent.setText(tmp);
} else {
mProgressPercent.setText("");
}
}
};
View view = inflater.inflate (R.layout.alert_dialog_progress, null); // alert_dialog_progress.xml 소스를 그대로 프로젝트 res폴더에 저장해놓음
-> 2.0MB / 4.0MB 와 같은 표시는 가능하지만, new ProgressDialog(mContext, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT) 를 해도 테마에 맞게 글자 색상 크기변경 되지 않음
2. CustomProgressDialog extends AlertDialog
android.app.ProgressDialog 소스코드를 복사해와서 그대로 사용하면 mProgress는 null이됨
CustomProgressDialog extends AlertDialog 정의후
onCreate에서
LayoutInflater inflater = LayoutInflater.from(mContext);
TypedArray a = mContext.obtainStyledAttributes(null,
com.android.internal.R.styleable.AlertDialog,
com.android.internal.R.attr.alertDialogStyle, 0);
View view = inflater.inflate(a.getResourceId(
com.android.internal.R.styleable.AlertDialog_horizontalProgressLayout,
R.layout.alert_dialog_progress), null);
mProgress = (ProgressBar) view.findViewById(R.id.progress); // mProgress 초기화 안됨
mProgressNumber = (TextView) view.findViewById(R.id.progress_number); //초기화 안됨
mProgressPercent = (TextView) view.findViewById(R.id.progress_percent); //초기화 안됨