因项目需要,需要一个弹出对话框,但对话框的布局和界面不是默认的,而是需要自己自定义的界面
(一)先实例化一个Builder对象
AlertDialog.Builder addDialog = new AlertDialog.Builder(Context);
参数:Context是上下文
(二)自定义布局add_address_dialog.xml,这个布局就是你自己弹出对话框的布局,我这里就要我的
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="26sp"
android:text="新增地址"
/>
<View style="@style/horizontal_layout"
android:id="@+id/titleLine"
android:layout_below="@+id/title"
android:layout_width="match_parent"
/>