MaterialTest学习笔记(四)感谢郭神
如何使用AlertDialog以及添加在其中输入框
首先看一下效果图:
新建一个空白Activity
修改activity_main.xml文件
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="button"/>
</android.support.constraint.ConstraintLayout>
修改MainActivity.class
package com.example.dialogt;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view