log.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="请输入密码" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="请输入姓名"/>
</LinearLayout>
AlertDialog.Builder builder = new Builder(this);
builder.setTitle("hello");
builder.setIcon(R.drawable.ic_launcher);
LayoutInflater inflater = getLayoutInflater();
View v = inflater.inflate(R.layout.login, null);
builder.setView(v);
builder.setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "hello", 1).show();
}
});
AlertDialog dialog = builder.create();
dialog.show();