android 自定义alertdialog和取消dialog
看代码:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
LayoutInflater inflater = getLayoutInflater();
View view1 = inflater.inflate(R.layout.alert, (ViewGroup) findViewById(R.id.alertdialog));
builder.setView(view1);
final AlertDialog dialog = builder.show();
view1.findViewById(R.id.btn_invent).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.e("tag", "onClick: "+"点击取消" );
dialog.dismiss();
}
});
}
});
}
}
要取消dialog先要获取dialog,再dismiss(),直接dismiss()是没有用的;
demo下载地址:https://github.com/renjiemei1225/AlertDialogTest2
android 自定义alertdialog和取消dialog的更多相关文章
- Android 自定义AlertDialog退出对话框
Android 自定义AlertDialog退出对话框 转 https://blog.csdn.net/wkh11/article/details/53081634在项目中很多时候会出现点击返回键出现 ...
- Android 自定义AlertDialog的实现
Android默认的AlertDialog太单调,我们可以通过继承原生的Dialog来实现自定义的Dialog. 本文的自定义Dialog和原生的AlertDialog的创建方式类似,通过一个静态Bu ...
- Android 自定义AlertDialog(退出提示框)
有时候我们需要在游戏或应用中用一些符合我们样式的提示框(AlertDialog) 以下是我在开发一个小游戏中总结出来的.希望对大家有用. 先上效果图: 下面是用到的背景图或按钮的图片 经过查找资料和参 ...
- Android自定义AlertDialog
常见的一种方法: [html] view plaincopyprint? AlertDialog.Builder builder; AlertDialog alertDialog; LayoutInf ...
- android 自定义AlertDialog(一段)
java: final AlertDialog dialog = new AlertDialog.Builder(mContext) .create(); dialog.setCancelable(f ...
- Android 自定义AlertDialog的写法和弹出软键盘和覆盖状态栏
private void showMyDialog(int layoutId){ AlertDialog myDialog = new AlertDialog.Builder(context).cre ...
- android 自定义AlertDialog
xml: alter_dialog_two <?xml version="1.0" encoding="utf-8"?> <LinearLay ...
- Android 自定义带回调的Dialog 及EditText相关
import android.app.Activity; import android.content.Context; import android.text.Editable; import ...
- Android之自定义AlertDialog和PopupWindow实现(仿微信Dialog)
我们知道,在很多时候,我们都不用Android内置的一些控件,而是自己自定义一些自己想要的控件,这样显得界面更美观. 今天主要是讲自定义AlertDialog和popupWindow的使用,在很多需求 ...
随机推荐
- [2016.01.22]万峰文本处理专家 v2.1
<万峰文本处理专家>是一款简单易用,且功能强大的各类文本文件处理软件.1.支持多任务的处理模式,允许一次处理多个任务.2.支持正则表达式替换,替换更加强大:3.支持各类关键字的行处理操作: ...
- Linux--02软件安装、防火墙设置
防火墙设置: With RHEL / CentOS , firewalld was introduced to manage iptables. IMHO, firewalld is more sui ...
- 黄聪:如何为IIS增加svg和woff等字体格式的MIME
现在字体图标已经渐渐代替了图片了,移动端用起来也很方便. 使用了字体文件来显示矢量的图标,为了能在IIS上正常显示图标,可以通过增加iis的MIME-TYPE来支持图标字体文件 下面就把IIS增加sv ...
- IOS开发 strong,weak,retain,assign,copy nomatic 等的区别与作用
strong,weak,retain,assign,copy nomatic 等的区别 copy与retain:1.copy其实是建立了一个相同的对象,而retain不是:2.copy是内容拷贝,re ...
- module
扯淡的人 http://www.cnblogs.com/yuanchenqi/articles/5732581.html 不被调用的 要写在这下面 1 if __name__=="__ ...
- CentOS7 配置阿里云yum源
1)下载repo文件 wget http://mirrors.aliyun.com/repo/Centos-7.repo 2)备份并替换系统的repo文件 cp Centos-7.repo /etc/ ...
- Xcode磁盘空间大清理
我的设备是Macbook Air 13' Mid 2011,128G SSD.最近开始有些存储压力了,用Clean My Mac清理一部分旧文件后,决定对Xcode动手. 移除对旧设备的支持 影响:可 ...
- JS获取form表单所有属性值
// 得到一个表单里的全部信息function getFormQueryString() { var frmID=document.forms[0]; var i,queryString=" ...
- mysql分组函数
组函数针对的是指定字段的非空值.注意:where子句中不能出现组函数!!! avg() 平均值(只能针对数值型 ) max() 最大值(不限制类型) min() 最小值(不限制类型) ...
- Python-0 简述
#1 应用广泛: 豆瓣 youtube 云存储相关 #2 初步学习内容: