The renderings are as follows:

The button on the left side of Dialog forgot to pay the password was written wrong

Function requirements ClickretryOpen againEnter the payment password pageClick on theForget your payment passwordjumpPassword Setting page

This Demo only demonstrates how to use AlertDialog and how to set resource propertiesIf you need other functions, please leave a message

  • This is a pay password input failure popbox with custom basic properties

XMl layoutdialog_common

<? The XML version = "1.0" encoding = "utf-8"? > <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:background="@drawable/commen_dialog_bg" > <android.support.v7.widget.AppCompatTextView android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" android:textSize="16sp" android:id="@+id/titleTv" app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="20dp" tools:text="dddddddddd" android:textColor="@android:color/black" /> <View android:id="@+id/line" android:layout_width="match_parent" android:layout_height="1px" app:layout_constraintTop_toBottomOf="@+id/titleTv" android:layout_marginTop="20dp" android:background="@color/colorPrimary"/> <TextView android:id="@+id/confirmBtn" android:layout_width="0dp" android:layout_height="wrap_content" android:minHeight="50dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toBottomOf="@+id/line" app:layout_constraintRight_toLeftOf="@+id/cancelBtn" Android :gravity="center"/> <TextView android:gravity="center"/> <TextView android:id="@+id/cancelBtn" android:layout_width="0dp" android:layout_height="wrap_content" android:minHeight="50dp" app:layout_constraintTop_toBottomOf="@+id/line" app:layout_constraintLeft_toRightOf="@+id/confirmBtn" App :layout_constraintRight_toRightOf="parent" Android :textColor="# 3478F6 "Android :textSize=" 16SP" Tools :text=" delete "app:layout_constraintRight_toRightOf="parent" android:gravity="center" /> <View android:layout_width="1px" android:layout_height="0dp" android:background="@color/colorPrimary" app:layout_constraintTop_toTopOf="@+id/confirmBtn" app:layout_constraintBottom_toBottomOf="@+id/confirmBtn" app:layout_constraintLeft_toRightOf="@+id/confirmBtn" /> </android.support.constraint.ConstraintLayout>Copy the code

Rounded box propertiescommen_dialog_bg

<? The XML version = "1.0" encoding = "utf-8"? > <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/colorWhite"/> <corners  android:radius="15dp"/> <size android:width="300dp"/> </shape>Copy the code

Styledialog_custom

<style name="dialog_custom" parent="@android:style/Theme.Dialog"> <item name="android:windowNoTitle">false</item> <! - is there a title - > < item name = "android: windowBackground" > @ android: color/transparent < / item > <! - background color transparent window - > < item name = "android: windowMinWidthMajor" > 80% < / item > < item name = "android: windowMinWidthMinor" > 80% < / item > </style>Copy the code

AlertDialogApply it in code

private void showPayFailedDialog(String message) { AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.dialog_custom); View customView = getLayoutInflater().inflate(R.layout.dialog_common, null); builder.setView(customView); AlertDialog mDialog = builder.create(); TextView titleTv = customView.findViewById(R.id.titleTv); TextView confirmBtn = customView.findViewById(R.id.confirmBtn); TextView cancelBtn = customView.findViewById(R.id.cancelBtn); titleTv.setText(message); If (message.contains(" password ")) {confirmbtn. setText(" forget to pay password "); } else {confirmbtn. setText(" confirmbtn. setText "); } cancelbtn. setText(" retry "); / / click event with Java8 lambda expressions confirmBtn. SetOnClickListener (view - > {mDialog. Dismiss (); If (message. The contains (" password ")) {startActivity (new Intent (this, PaySettingsActivity. Class)); }}); / / same as above cancelBtn. SetOnClickListener (view - > {mDialog. Dismiss (); showPayDialog(); }); mDialog.show(); }Copy the code

Share with you

I want to work my way up

Fly forward on the blades at the highest point

Let the wind blow dry tears and sweat

I want to work my way up

Waiting for the sun to watch its face

Little days have big dreams

I have my day

Let the wind blow dry tears and sweat

One day I will have my day