android 各种提示 Dialog 弹出框
messageTv.setVisibility(View.GONE);
} else {
messageTv.setText(message)
;
messageTv.setVisibility(View.VISIBLE);
}
return dialog;
}
public static Dialog getCustomDialog(final Activity activity, View view, boolean dismissTouchOutside,
boolean cancelable, int theme) {
//Dialog dialog = theme > 0 ? new FullScreenDialogHUD(activity, theme)
// : new Dialog(activity, R.style.Dialog_FullScreen);
Dialog dialog = new Dialog(activity, R.style.Dialog_FullScreen);
dialog.setContentView(view);
dialog.setCancelable(cancelable);
dialog.setCanceledOnTouchOutside(dismissTouchOutside);
if (!cancelable) {
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
dialog.dismiss();
activity.finish();
}
return false;
}
});
}
return dialog;
}
public static Dialog getOneButtonDialog(final Activity activity, String content,
boolean dismissTouchOutside, boolean cancelable,
DialogInterface.OnClickListener confirmOnClickListener) {
Dialog dialog = new AlertDialog.Builder(activity)
.setPositiveButton(R.string.confirm, confirmOnClickListener)
.setCancelable(cancelable)
.setMessage(content)
.create();
dialog.setCanceledOnTouchOutside(dismissTouchOutside);
if (!cancelable) {
dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
dialog.dismiss();
activity.finish();
}
return false;
}
});
}
return dialog;
}
public static Dialog getButtonsDialog(Activity activity, int resId,
DialogInterface.OnClickListener confirmOnClickListener) {
return getButtonsDialog(activity, activity.getString(resId), true, true, confirmOnClickListener,
null);
}
public static Dialog getButtonsDialog(Activity activity, String content,
DialogInterface.OnClickListener confirmOnClickListener) {
return getButtonsDialog(activity, content, true, true, confirmOnClickListener, null);
}
public static Dialog getButtonsDialog(Activity activity, String content, boolean dismissTouchOutside,
boolean cancelable, DialogInterface.OnClickListener confirmOnClickListener,
DialogInterface.OnClickListener cancelOnClickListener) {
Dialog dialog = new AlertDialog.Builder(activity)
.setNegativeButton(R.string.cancel, cancelOnClickListener)
.setPositiveButton(R.string.confirm, confirmOnClickListener)
.setCancelable(cancelable)
.setMessage(content)
.create();
dialog.setCanceledOnTouchOutside(dismissTouchOutside);
return dialog;
}
progress_hud.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
android:background="@android:color/transparent">
<ImageView
android:id="@+id/spinnerImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@anim/spinner"/>
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
评论