Android自定义网络访问对话框

public class ECProgressDialog extends Dialog {

private TextView mTextView;
private View mImageView;
AsyncTask mAsyncTask;

private final OnCancelListener mCancelListener = new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if(mAsyncTask != null) {
mAsyncTask.cancel(true);
}
}
};

/**
* @param context
*/
public ECProgressDialog(Context context) {
super(context , R.style.Theme_Light_CustomDialog_Blue);
mAsyncTask = null;
setCancelable(true);
setContentView(R.layout.common_loading_diloag);
mTextView = (TextView)findViewById(R.id.textview);
mImageView = findViewById(R.id.imageview);
setOnCancelListener(mCancelListener);
}

/**
* @param context
* @param resid
*/
public ECProgressDialog(Context context, int resid) {
this(context);
mTextView.setText(resid);
}

public ECProgressDialog(Context context, CharSequence text) {
this(context);
mTextView.setText(text);
}

public ECProgressDialog(Context context, AsyncTask asyncTask) {
this(context);
mAsyncTask = asyncTask;
}

public ECProgressDialog(Context context, CharSequence text, AsyncTask asyncTask) {
this(context , text);
mAsyncTask = asyncTask;
}

/**
* 设置对话框显示文本
* @param text
*/
public final void setPressText(CharSequence text) {
mTextView.setText(text);
}

public final void dismiss() {
try {
super.dismiss();
mImageView.clearAnimation();
}catch (Exception ex){
ex.printStackTrace();
}
}

public final void show() {
super.show();
Animation loadAnimation = AnimationUtils.loadAnimation(getContext() ,R.anim.loading);
mImageView.startAnimation(loadAnimation);
}

}

关注公众号“大模型全栈程序员”回复“小程序”获取1000个小程序打包源码。更多免费资源在http://www.gitweixin.com/?p=2627

发表评论

邮箱地址不会被公开。 必填项已用*标注