写点什么

android 各种提示 Dialog 弹出框

用户头像
Android架构
关注
发布于: 2021 年 11 月 07 日

messageTv.setVisibility(View.GONE);


} else {


messageTv.setText(message)


《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》
浏览器打开:qq.cn.hn/FTe 免费领取
复制代码


;


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"

用户头像

Android架构

关注

还未添加个人签名 2021.10.31 加入

还未添加个人简介

评论

发布
暂无评论
android各种提示Dialog  弹出框