1.带输入框的AlertDialog
//创建AlertDialog
AlertDialog.Builder builder=new AlertDialog.Builder(Personal_Data.this);
View mView=View.inflate(Personal_Data.this,R.layout.dialog_layout,null);
builder.setView(mView);
//确定按钮
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
EditText mNameEdit = mView.findViewById(R.id.nameEdit);
String nickName = mNameEdit.getText().toString();
});
//取消按钮
builder.setNegativeButton("取消",null);
builder.show();
2.自定义布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="修改昵称:"
android:textSize="@dimen/sp_16"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/nameEdit"
android:background="@drawable/search_shape"/>
</LinearLayout>
3.简单弹框
AlertDialog.Builder builder=new AlertDialog.Builder(Personal_Data.this);
//设置标题
builder.setTitle("修改昵称");
//设置内容
builder.setMessage("修改密码");
//确定按钮
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//personalDataName.
}
});
//取消按钮
builder.setNegativeButton("取消",null);
//设置展示
builder.show();