AlertDialog两三事
2016-09-20 15:56
106 查看
AlertDialog为什么要Buider呢?直接构造如何不成功?
一:AlertDialog与AlertDialog.Builder
AlertDialog是Dialog的一个直接子类,最常用的对话框之一,注意不能直接用构造函数 AlertDialog alertDialog = new AlertDialog(mContent)来得到一个AlertDialog;
AlertDialog.Builder才是得到AlertDialog的唯一方式:AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
很多人会为了dialog出现后,点击空白处或者按返回键的控制处理烦恼,以下方法能很好地帮助到你:
二:AlertDialog.Builder的setCancelable
alertDialog.setCancelable(true/false); //设置为false,按返回键不能退出,默认为true。
三:AlertDialog.Builder的setCanceledOnTouchOutside
alertDialog.setCanceledOnTouchOutside(true/false); // 设置为false则dialog弹出后会点击屏幕,dialog不消失;点击物理返回键dialog消失。
PS:附送dialog从下慢慢上升进入及慢慢落下退出的动画效果实现代码:
一:AlertDialog与AlertDialog.Builder
AlertDialog是Dialog的一个直接子类,最常用的对话框之一,注意不能直接用构造函数 AlertDialog alertDialog = new AlertDialog(mContent)来得到一个AlertDialog;
AlertDialog.Builder才是得到AlertDialog的唯一方式:AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
很多人会为了dialog出现后,点击空白处或者按返回键的控制处理烦恼,以下方法能很好地帮助到你:
二:AlertDialog.Builder的setCancelable
alertDialog.setCancelable(true/false); //设置为false,按返回键不能退出,默认为true。
三:AlertDialog.Builder的setCanceledOnTouchOutside
alertDialog.setCanceledOnTouchOutside(true/false); // 设置为false则dialog弹出后会点击屏幕,dialog不消失;点击物理返回键dialog消失。
PS:附送dialog从下慢慢上升进入及慢慢落下退出的动画效果实现代码:
dialog = new Dialog(context, R.style.ActionSheetDialogStyle);
<style name="ActionSheetDialogStyle" parent="@android:style/Theme.Dialog"> <!-- Dialog进入及退出动画 --> <item name="android:windowAnimationStyle">@style/ActionSheetDialogAnimation</item> </style>
<style name="ActionSheetDialogAnimation" parent="@android:style/Animation.Dialog"> <item name="android:windowEnterAnimation">@anim/actionsheet_dialog_in</item> <item name="android:windowExitAnimation">@anim/actionsheet_dialog_out</item> </style>
<!--actionsheet_dialog_in-->
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="300" android:fromYDelta="100%" android:toYDelta="0" />
<!--actionsheet_dialog_out-->
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="300" android:fromYDelta="0" android:toYDelta="100%" />
相关文章推荐
- jquery动画效果学习笔记(8种效果)
- jQuery中实现动画效果的基本操作介绍
- 图片的左右移动,js动画效果实现代码
- 实现动画效果核心方式的js代码
- Android UI设计之AlertDialog弹窗控件
- Android编程之自定义AlertDialog(退出提示框)用法实例
- Android使用自定义alertdialog实现确认退出按钮
- Android中AlertDialog用法实例分析
- Android中阻止AlertDialog关闭实例代码
- Android AlertDialog对话框用法示例
- Android中AlertDialog的六种创建方式
- Android修改源码解决Alertdialog触摸对话框边缘消失的问题
- Android实现点击AlertDialog上按钮时不关闭对话框的方法
- 简析Android多种AlertDialog对话框效果
- Android入门之AlertDialog用法实例分析
- javascript 通用loading动画效果实例代码
- 给angular加上动画效遇到的问题总结
- IOS框架Spring常用的动画效果
- IOS等待时动画效果的实现
- Android中AlertDilog显示简单和复杂列表的方法