android showDialog用法
2024-08-27 22:16:17
protected Dialog onCreateDialog(int id) {
// TODO Auto-generated method stub
switch(id){
case 10:
return new AlertDialog.Builder(Activity13.this)
.setTitle(getString(R.string.title)).setMessage(
getString(R.string.timeout)).setPositiveButton(
getString(R.string.ok),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
}).create(); }
return super.onCreateDialog(id);
}
调用:
showDialog(10);
自定义的view:
View dialogView=(LinearLayout) getLayoutInflater().inflate(R.layout.dialog_addip,null);
final AlertDialog.Builder builder =new AlertDialog.Builder(Demo12Activity.this);
builder.setView(dialogView);
showBtn = (Button)findViewById(R.id.show);
showBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//这
builder.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:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="210dp"
android:background="@drawable/radius_5dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:padding="12dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="20dp"
android:textColor="#f75830"
android:textSize="18dp"
android:text="添加ip"/> </LinearLayout> </LinearLayout>
最新文章
- Sql Service 的job作业新建过程
- WPF 画心2.0版之元旦快乐
- phpcmsv9多表联合查询分页功能实现
- web基础知识小记
- C# Winform学习---MDI窗体的设计,PictureBox控件(图片上一页下一页),Timer控件,MenuStrip控件
- Android内存Activity泄露:Threads
- C#泛型(二)
- 如何添加WebService调用时的用户认证
- php返回相对时间(如:20分钟前,3天前)的方法
- Powershell 快捷键
- 上下文菜单与TrackPopupMenu
- mysql 安装及卸载 主从配置
- C# 中枚举的一点研究(跳过一些net坑的研究而已)
- 菜鸟容易中的招__setattr__
- 超实用的JavaScript代码段 Item5 --图片滑动效果实现
- 一张图让你懂Python安装第三方库
- Alibaba, I&#39;m interested in you.
- centos7.2安装图文详解
- Android:E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f9d1b41c0
- opencv中mat类介绍
热门文章
- shell脚本程序中循环、判断语句的介绍
- MFC中编辑框Edit Control添加“变量”后
- VC++ :传统剪贴板的延迟提交技术
- VC++ 打开文件或文件夹对话框的实现方法
- 【iOS与EV3混合机器人编程系列之三】编写EV3 Port Viewer 应用监測EV3port数据
- Java精选笔记_面向对象(构造方法、this关键字、static关键字、内部类)
- 在线学习angularjs2
- shell基础(八)-循环语句
- 【RF库Collections测试】Convert To List
- 关于微信的jsdk的若干亲身实践之小结