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的使用,在很多需求 ...
随机推荐
- NSUserDefault的使用
NSUserDefaults 在我们编写代码中是最常用的一个永久保存数据的方法,也是最简单的. 使用NSUserDefault需要注意: 1.数据的本地化保存不是实时的,如果需要实时保存,调用sync ...
- [转]C#程序无法在64位系统上运行之.NET编译的目标平台
今天将编译的C#的exe拷贝到测试机上(Win7_64bit),一运行就挂了,提示“stop working”,一开始怀疑测试机上没有安装.net framework框架,追究半天原来是编译的目标平台 ...
- OLDB读取excel的数据类型不匹配的解决方案(ZT)
1 引言 在应用程序的设计中,经常需要读取Excel数据或将Excel数据导入转换到其他数据载体中,例如将Excel数据通过应用程序导入SQL Sever等数据库中以备使用.笔者在开发“汽车产业链A ...
- html: title换行方法 如a链接标签内title属性鼠标悬停提示内容换行
换行代码符合分别为: “&#;”和“&#;” <a href="0.shtml" title="第一排 第二排 第三排">title ...
- ios7 tableview scrollsToTop 不执行处理方法
ios7中调用[self.tableview scrollsToTop] 没有效果(ios8中也没有效果) stackflow 处理方法: [self.tableviewscrollRectToVis ...
- a new blog from MarsEdit
终于在网上找到了一款mac 下的blog写作和发布工具了. 先测试一下.
- Nhibernate对应关系参数介绍
一.多对一关联映配置介绍 <many-to-one name="PropertyName" 属性名 column="column_name" 数据库字段名 ...
- 使用百度地图API产生指定范围的随机点
直接上代码: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...
- .NET MEF入门级例子
学习新东西,喜欢从简单的例子入手,感觉理解和上手会快点,本文记录下我做的一个简单的mef的例子,至于理论的话百度,谷歌多的去了. Mef可以在你调整了某些功能的时候不需要重新去做代码,只需要换掉相应的 ...
- 【HEVC】1、HM-16.7编码器的基本结构
编码器在整个HM解决方案中的工程名为TAppEncoder,入口点函数位于encmain.cpp文件中: int main(int argc, char* argv[]) { TAppEncTop c ...