嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
自定义进度框
package com.example.customprogressdialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.TextView;
/**
*
* <p>Title: 自定义进度对话框 </p>
* <p>Description:
* 1.單例模式,獲取唯一的實例
* 2.繼承Dialog
* 3.可以設置標題、設置顯示信息
* </p>
* <p>@author: jieyang </p>
* <p>Copyright: Copyright (c) 2012 </p>
* <p>Company: FFCS Co., Ltd. </p>
* <p>Create Time: 2013-8-23 </p>
* <p>Update Time: </p>
* <p>Updater: </p>
* <p>Update Comments: </p>
*/
public class CustomProgressDialog extends Dialog {
private Context context;
private static CustomProgressDialog cpd;
public CustomProgressDialog(Context context) {
super(context);
this.context = context;
}
public CustomProgressDialog(Context context, int theme) {
super(context,theme);
}
public static CustomProgressDialog getInstance(Context context){
if(cpd == null){
cpd = new CustomProgressDialog(context,R.style.CustomProgressDialog);
//設置View
cpd.setContentView(R.layout.act_custom_progressdialog);
//設置居中顯示
cpd.getWindow().getAttributes().gravity = Gravity.CENTER;
}
return cpd;
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
if(cpd == null){
return;
}
ImageView ivLoad = (ImageView) cpd.findViewById(R.id.ivLoad);
AnimationDrawable ad = (AnimationDrawable) ivLoad.getBackground();
ad.start();
}
/**
* 設置標題
* @param title 標題
* @return
*/
public CustomProgressDialog setTitle(String title) {
return cpd;
}
/**
* 設置信息
* @param msg 信息
* @return
*/
public CustomProgressDialog setMessage(String msg) {
TextView tvLoadMsg = (TextView) cpd.findViewById(R.id.tvLoadMsg);
if(tvLoadMsg != null){
tvLoadMsg.setText(msg);
}
return cpd;
}
}