**主要实现功能:**
1、从Activity的TextView中获取字符串设置到AlertDialog的TextView和EditText中
2、将AlertDialog的EditText中的值设置到Activity的TextView中
效果:
![](https://box.kancloud.cn/2016-03-01_56d5568e48191.jpg)
![](https://box.kancloud.cn/2016-03-01_56d5568e62672.jpg)
![](https://box.kancloud.cn/2016-03-01_56d5568e78363.jpg)
新手在自定义AlertDialog上的疑问笔者猜测主要有**两个**:
1、自定义的layout如何放到AlertDialog中?
解答:
获取到layout的view之后,直接调用AlertDialog.Builder的setView方法即可。
2、如何对自定义AlertDialog中的控件进行操作?
解答:
于fragment中的操作类似,首先要获取该layout的view,然后通过该view获取到其中控件进行操作。
MainActivity:
~~~
package com.example.myalertdialog;
import android.app.Activity;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.Ap