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();
<?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();
相关文章推荐
- 解决git本地多ssh key的问题
- bestcoder # 83
- Andorid动画机制与使用技巧
- 让你提升命令行效率的 Bash 快捷键 [完整版]
- Spark集群无法停止的原因分析和解决
- 大二了,用csdn也有好几个年头了,也该开始开始记录整理一些生活中的资料了,说不定什么时候就成大牛了。哇咔咔
- MATLAB中的点运算
- Problem J: Arithmetic Sequence
- log4j配置文件中的additivity属性
- Python笔记之入门(基础篇)
- 在win10 x64下配置QT5.6.0 Mingw+opencv2.4.12
- FPGA约束文件
- 深度遍历和广度遍历,邻接表和邻接矩阵
- Linux发行版 CentOS6.5下删除分区操作
- Binder学习笔记(九)—— 服务端如何响应Test()请求 ?
- Nofication的使用
- ftrace kprobe调试
- 关于 @synchronized,这儿比你想知道的还要多
- PHP语言 -- Smarty函数
- Android实现Banner界面广告图片循环轮播(包括实现手动滑动循环)