java 警报对话框(标题,内容,2个按钮)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 警报对话框(标题,内容,2个按钮)相关的知识,希望对你有一定的参考价值。

<style name="AppTheme_AlertDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
    <!-- Title -->
    <item name="android:textColor">@android:color/black</item>
    <!-- Content -->
    <item name="android:textColorPrimary">@color/grey</item>
    <!-- Buttons -->
    <item name="colorAccent">@color/colorAccent</item>
</style>
public void showSignUpAlertDialog(boolean fromSignUpButton) {
    String title, message;
    if (fromSignUpButton) {
        title = mContext.getString(R.string.action_sign_up_short);
        message = mContext.getString(R.string.dialog_sign_up_text);
    } else {
        title = mContext.getString(R.string.account_not_found_title);
        message = mContext.getString(R.string.account_not_found_text_social_login);
    }

    AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        builder = new AlertDialog.Builder(mActivityReference,
            R.style.AppTheme_AlertDialog);
        // android.R.style.Theme_Material_Light_Dialog_NoActionBar
    } else {
        builder = new AlertDialog.Builder(mActivityReference);
    }
    builder.setTitle(title)
        .setMessage(message)
        .setPositiveButton(mContext.getString(R.string.proceed), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                openBrowserLink(
                    BuildConfig.APP_URL +
                    mContext.getString(R.string.url_provider_onboarding));
            }
        })
        .setNegativeButton(mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // Cancel Click Button
            }
        })
        .show();
}

以上是关于java 警报对话框(标题,内容,2个按钮)的主要内容,如果未能解决你的问题,请参考以下文章

警报对话框 - 如何?

如何防止警报对话框被后退按钮关闭

带有一个、两个和三个按钮的 Android 警报对话框

带有一个、两个和三个按钮的 Android 警报对话框

NativeScript iOS 警报对话框按钮颜色

如何使用此按钮中的条件在颤动中显示警报对话框?