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TZkRhm3meifWa3HQfmqfbVMF42TjRaPHYnpdndZxvW680Txi+0u3mh2qfdNwpD46wsq70Vv8R+efQ75hYWRGuLWZm3Qi0n4yqIIh7dZcoq9mdUqdv7bffnnf+qbh+6Y/RVh5F5qvnGq8FGHlafpKLjkTQr5h4WjG9raZ2/joQXLiZKT95CYLBpuasfpLdIKqt/jBq4rmCdf1FypN362sTmmj18l2KrcH7//eERfyDQsvM7a3zdwFJ4ItGBear8wszf59qPzWy/utk+5//me4atSu6bsVYeU99JjZVsP25om6ryTkGxYuZlx2pO7so8d2tJnrnGALRhDd4uG6M8bXloR26t7wI+ev7QMzg5Wva/3NOGg/2eh1/jxi3W87EfI9Cy8zwtYJohZf8EhiePVz00RLx9SLOFd61ag9hhayZhhfW0yvq8tfVV5tuyZoy7gz+CDkexZGZoRDm7l5JyLtUUEVDDZUl+xIffTdoYf7bSeuv1DdHtQnPcuJsPJ+aL6c5r4u79Gx0wr7b5/4R0zIty30ZvzoSAm3k6tPO/Fei0h7FJ5u7a4Z4XH72NiJSHvU/08rEAZmhOLkKqjbh3+wYOyWGeHdUnCCBSMEZoTHKcUnnThgizpgw4Kxu2aEkxMELVgnDtiwYGxnYhrjNzLDMmxPaKH8co2Tq9xkcSJ0chPvzFyXDE4ExNDpnMQF5rIj9UdHCmbruexIrflX/UZmIAgLmoGQQTMQMmgGQgbNQMigGQgZNAMhg2YgZNAMhAyagZBBMxAyaAZCBs1AyKAZCBk0AyGDZiBk/gtgxwQ6QGnYPwAAAABJRU5ErkJggg==" alt="" />

1.自定义dialog的用法

YouMengDialog userMsgDialog=null;
private void initTipDialog() {
userMsgDialog = new YouMengDialog (this);
userMsgDialog.setTitle("系统提示!");
userMsgDialog.setMessage("提示的内容!");
userMsgDialog.setCanceledOnTouchOutside(false);
    userMsgDialog.setButton1("取消", new View.OnClickListener() {
@Override
public void onClick(View v) {
userMsgDialog.dismiss(); }
});
    userMsgDialog.setButton2("确定", new View.OnClickListener() {
@Override
public void onClick(View v) {
userMsgDialog.dismiss(); }
});
userMsgDialog.show();
}

 

2.dialog的java代码

public class YouMengDialog extends Dialog {
private View contentView;
public YouMengDialog(Context context){
super(context, R.style.tran_AlertDialog);
LayoutInflater inflater = LayoutInflater.from(context);
this.contentView = inflater.inflate(R.layout.dialog, null);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(contentView);
Window window = this.getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
Display d = window.getWindowManager().getDefaultDisplay();
lp.width = (int) (d.getWidth() * 0.9F);
window.setAttributes(lp);
} //设置提示框标题
public void setTitle(String title){
final TextView textView = (TextView) contentView.findViewById(R.id.title);
textView.setText(title);
}
//设置提示的内容
public void setMessage(String message){
final TextView textView = (TextView) contentView.findViewById(R.id.message);
textView.setText(message);
}
//对提示框的第一个按键(取消按钮)设置,title:按钮上的文字,onclicklistener :触发的事件
public void setButton(String title,View.OnClickListener onClickListener){
final Button button = (Button) contentView.findViewById(R.id.dialogButton);
button.setText(title);
button.setOnClickListener(onClickListener);
} //当只需要一个确定键的时候让取消键隐藏
public void setButtonGone(){
Button button = (Button) contentView.findViewById(R.id.dialogButton);
button.setVisibility(View.GONE); }
//对提示框的第二个按键(确定按钮)设置,title:按钮上的文字,onclicklistener :触发的事件
    public void setButton2(String title,View.OnClickListener onClickListener){
final Button button = (Button) contentView.findViewById(R.id.dialogButton2);
button.setText(title);
button.setOnClickListener(onClickListener);
}
}

3.用到的样式表
<style name="tran_AlertDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<!-- 边框 -->
<item name="android:windowIsFloating">true</item>
<!-- 是否浮现在activity之上 -->
<item name="android:windowIsTranslucent">true</item>
<!-- 半透明 -->
<item name="android:windowNoTitle">true</item>
<!-- 无标题 -->
<item name="android:windowBackground">@drawable/gray_corners_border</item>
<!-- 自己想要的背景 -->
<item name="android:backgroundDimEnabled">true</item>
<!-- 模糊 -->
</style>

4.dialog的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/gray_bottom_border"
android:padding="10dp"
android:gravity="center_vertical">
<ImageView
android:src="@drawable/jinggao"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxWidth="25dp"
android:maxHeight="25dp"
android:scaleType="fitCenter"
android:layout_marginRight="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提示信息"
android:id="@+id/title"
android:textColor="@color/black"
android:textSize="@dimen/txt_20"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提示信息"
android:id="@+id/message"
android:textColor="@color/black"
android:textSize="@dimen/txt_20"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="10dp"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="取消"
android:background="@drawable/gray_corners_button"
android:id="@+id/dialogButton"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp" android:textSize="@dimen/txt_20"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="确认"
android:background="@drawable/green_corners_button"
android:id="@+id/dialogButton2"
android:textSize="@dimen/txt_20"
android:textColor="@color/white"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="1" />
</LinearLayout></LinearLayout>
 
 

通用的Dialog自定义dialog的更多相关文章

  1. Animate a custom Dialog,自定义Dialog动画

    Inside res/style.xml <style name="AppTheme" parent="android:Theme.Light" /> ...

  2. CustomDialog——一个多功能、通用、可自定义的Dialog

    CustomDialog--一个多功能.通用.可自定义的Dialog  依赖 compile 'com.github.SiberiaDante:CustomDialog:v1.0.1'  说明[Cus ...

  3. C/C++ Qt 自定义Dialog对话框组件应用

    在上一篇博文 <C/C++ Qt 标准Dialog对话框组件应用> 中我给大家演示了如何使用Qt中内置的标准对话框组件实现基本的数据输入功能. 但有时候我们需要一次性修改多个数据,使用默认 ...

  4. Android—自定义Dialog

    在 Android 日常的开发中,Dialog 使用是比较广泛的.无论是提示一个提示语,还是确认信息,还是有一定交互的(弹出验证码,输入账号密码登录等等)对话框. 而我们去看一下原生的对话框,虽然随着 ...

  5. Android自定义Dialog(美化界面)

    前言:在做项目的时候,发现dialog界面太丑陋,从csdn上下载了一份自定义dialog的源码,在他的基础上对界面进行美化...有需要的朋友可以直接拿走 效果图如下: 主要代码: /** * 自定义 ...

  6. Android自定义Dialog及其布局

     实际项目开发中默认的Dialog样式无法满足需求,需要自定义Dialog及其布局,并响应布局中控件的事件. 上效果图: 自定义Dialog,LogoutDialog: 要将自定义布局传入构造函数中, ...

  7. 自定义Dialog宽度占满屏幕

    一.自定义Dialog继承Dialog public class MyDialog extends Dialog { 二.为Dialog设置样式 在style中建立新样式继承 @android:sty ...

  8. 关于实现自定义Dialog和实现Dialog里view的事件监听的两种方法

    一.自定义dialog. 二.实现dialog里view的事件监听 1.自定义dialog比较简单.在实例化new的时候,加入样式,布局就行了.或者重写dialog. 2.实现dialog里view的 ...

  9. 自定义Dialog之信息提示

    对话框对于应用也是必不可少的一个组件,在Android中也不例外,对话框对于一些提示重要信息,或者一些需要用户额外交互的一些内容很有帮助. 自定义Dialog步骤: 1.主要创建Java类,并继承Di ...

随机推荐

  1. 感恩回馈,《ASP.NET Web API 2框架揭秘》免费赠送

      在继<WCF全面解析(上下册)>.<ASP.NET MVC 4框架揭秘>之后,我的另一本书<ASP.NET Web API 2框架揭秘>( 本书详细信息见< ...

  2. 为 Neutron 准备物理基础设施(I) - 每天5分钟玩转 OpenStack(75)

    前面讨论了 Neutron 的架构和基础知识,接下来就要通过实验深入学习和实践了. 第一步就是准备实验用的物理环境,考虑如下几个问题: 需要几个节点? 如何分配节点的角色? 节点上部署哪些服务? 配几 ...

  3. (十八)WebGIS中清空功能和地图定位功能的设计以及实现

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.背景 当地图中增加了很多元素后,对不同的元素需要进行一定的控制,最 ...

  4. TreeView控件使用

    treeView1.SelectedNode = treeView1.Nodes[0];  //选中当前treeview控件的根节点为当前节点添加子节点:  TreeNode tmp; tmp = n ...

  5. PHP实现实现数字补零格式化

    在接支付SDK的时候,第三方回调处理时需要IP,并且IP的需求是:去掉点号,补零到每地址段3位, 如:192168000001 先看看我的实现: <?php $IP = explode ( '. ...

  6. 小白Linux入门 一

    1 win7电脑上安装虚拟机,准备文件 vmware 12 http://www.orsoon.com/Soft/89658.html ubuntu 16.04  http://cn.ubuntu.c ...

  7. 在Mac上使用Visual Studio Code开发/调试.NET Core代码

    .Net Core 1.0终于发布了,Core的一大卖点就是跨平台.这个跨平台不只是跨平台运行,而且可以跨平台开发.今天抽空研究了下在Mac下如何使用VS Code来开发.NET Core程序,并且调 ...

  8. 【那些年关于MyEclipse的快捷键大全】

    MyEclipse 快捷键1(CTRL)-------------------------------------Ctrl+1 快速修复Ctrl+D: 删除当前行 Ctrl+Q  定位到最后编辑的地方 ...

  9. Effective java笔记(七),通用程序设计

    45.将局部变量的作用域最小化 将局部变量的作用域最小化,可以增强代码的可读性和可维护性,并降低出错的可能性. Java允许在任何可以出现语句的地方声明变量(C语言中局部变量要在代码块开头声明),要使 ...

  10. 体验VS2015 Update 2 的 Android 和 Python

    趁着假期不用加班,又遇到build 2016的劲爆消息--Xamarin免费集成到VS中 所以立马把vs升级到update 2体验一下下(之前也体验过). 在安装的时候也是只勾选了部分,不需要太多(全 ...