public static LoadingDialog getLoadingDialog(Context context) { loadingDialog = new LoadingDialog(context, R.style.LoadingDialog); loadingDialog.setContentView(R.layout.view_loading); loadingDialog.getWindow().getAttributes().gravity = Gravity.CENTER; // 加载动画 animation = AnimationUtils.loadAnimation(context, R.anim.anim_load); loadingDialog.setCancelable(true); return loadingDialog; }
/** * [Summary] setMessage 提示内容 * * @param strMessage * @return */ public LoadingDialog setMessage(String strMessage) { TextView tvMsg = (TextView) loadingDialog.findViewById(R.id.dialog_loadingcontent); if (tvMsg != null) { tvMsg.setText(strMessage); } return loadingDialog; }
public void onWindowFocusChanged(boolean hasFocus) { if (loadingDialog == null) { return; } ImageView loadImage = (ImageView) loadingDialog.findViewById(R.id.loading); // 使用ImageView显示动画 loadImage.startAnimation(animation); }