您的位置:首页 > 其它

Dialog如何实现显示自定义内容

2016-05-15 15:32 344 查看
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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: