java:

  final AlertDialog dialog = new AlertDialog.Builder(mContext)
.create();
dialog.setCancelable(false);
dialog.show();
dialog.getWindow().setContentView(R.layout.enable_gps_dialog);
Button unagree_dialog = (Button) dialog.getWindow()
.findViewById(R.id.unagree_dialog);
Button agree_dialog = (Button) dialog.getWindow().findViewById(
R.id.agree_dialog);
unagree_dialog.setOnClickListener(new OnClickListener() { @Override
public void onClick(View view) {
dialog.dismiss();
}
}); agree_dialog.setOnClickListener(new OnClickListener() { @Override
public void onClick(View view) {
dialog.dismiss();
mAutoSign.setImageResource(R.drawable.sign_auto_open);
SettingHelper.setAutoSignin(mContext, true);
// 打开 gps
HcUtil.openGPS(mContext);
// 网络判断
if (!HcUtil.isNetworkConnected(mContext)) {
HcUtil.showToast(HcApplication.getContext(),
R.string.open_netdata);
} // 开启自动打卡的闹钟
HcUtil.startAutoSignAlarm(mContext);
}
});

xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="264dip"
android:layout_height="wrap_content"
android:background="@drawable/gps_netdata_bg"
android:padding="5dip"
android:orientation="vertical" > <TextView
android:id="@+id/net_gps_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="15dip"
android:lines=""
android:lineSpacingExtra="5dip"
android:text="@string/enable_gps_text"
android:textColor="@color/text_tab"
android:textSize="15sp" /> <View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="@color/gps_divider_color" /> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/dialog_button_height"
android:orientation="horizontal" > <Button
android:id="@+id/unagree_dialog"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight=""
android:background="@android:color/white"
android:text="@string/unagree"
android:textColor="@color/gps_dialog_btn"
android:textSize="19sp" /> <View
android:layout_width="1dip"
android:layout_height="fill_parent"
android:visibility="gone"
android:background="@color/dialog_black" /> <Button
android:id="@+id/agree_dialog"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight=""
android:background="@android:color/white"
android:text="@string/agree"
android:textColor="@color/gps_dialog_btn"
android:textSize="19sp" />
</LinearLayout> </LinearLayout>

android 自定义AlertDialog(一段)的更多相关文章

  1. Android 自定义AlertDialog退出对话框

    Android 自定义AlertDialog退出对话框 转 https://blog.csdn.net/wkh11/article/details/53081634在项目中很多时候会出现点击返回键出现 ...

  2. Android 自定义AlertDialog的实现

    Android默认的AlertDialog太单调,我们可以通过继承原生的Dialog来实现自定义的Dialog. 本文的自定义Dialog和原生的AlertDialog的创建方式类似,通过一个静态Bu ...

  3. Android自定义AlertDialog

    常见的一种方法: [html] view plaincopyprint? AlertDialog.Builder builder; AlertDialog alertDialog; LayoutInf ...

  4. Android 自定义AlertDialog(退出提示框)

    有时候我们需要在游戏或应用中用一些符合我们样式的提示框(AlertDialog) 以下是我在开发一个小游戏中总结出来的.希望对大家有用. 先上效果图: 下面是用到的背景图或按钮的图片 经过查找资料和参 ...

  5. Android 自定义AlertDialog的写法和弹出软键盘和覆盖状态栏

    private void showMyDialog(int layoutId){ AlertDialog myDialog = new AlertDialog.Builder(context).cre ...

  6. android 自定义alertdialog和取消dialog

    看代码: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle ...

  7. android 自定义AlertDialog

    xml: alter_dialog_two <?xml version="1.0" encoding="utf-8"?> <LinearLay ...

  8. Android之自定义AlertDialog和PopupWindow实现(仿微信Dialog)

    我们知道,在很多时候,我们都不用Android内置的一些控件,而是自己自定义一些自己想要的控件,这样显得界面更美观. 今天主要是讲自定义AlertDialog和popupWindow的使用,在很多需求 ...

  9. Xamarin.Android 记事本(二)自定义AlertDialog

    导读 1.自定义一个AlertDialog 2.添加一条数据 正文 记事本应当有一个添加功能,这里我打算在右上角放一个item,然后点击这个item弹出一个对话框,输入名称,点击确定跳转到另一个act ...

随机推荐

  1. FPGA系统中DRAM,SRAM,SDRAM,FLASH 区别(转)

    原文:http://hi.baidu.com/abners/item/a9042ef35d3f005bc8f337f5 一般来说这几种存储器是一个nios系统都具有的,sram的好处是接口简单,速度快 ...

  2. 软件测试-nextDate问题

    NextDate 函数包含三个变量:month . day 和 year ,函数的输出为输入日期后一天的日期. 例如,输入为 2006年3月 7日,则函数的输出为 2006年3月8日 .要求输入变量  ...

  3. 一起来学canvas (前言)

    codeyy - 一依丫丫 一起来学canvas (前言)

  4. Windows SVN变化邮件通知(Python2.7实现)

    1,新增文件post-commit.bat 内容: rem REPOS-PATH (the path to this repository) set REPOS=%1 rem REV (the num ...

  5. Zookeeper 1、Zookeeper 定义与工作原理

    1.什么是Zookeeper » Zookeeper 是 Google 的 Chubby一个开源的实现,是 Hadoop 的分布式协调服务 » 它包含一个简单的原语集,分布式应用程序可以基于它实现同步 ...

  6. Java安装根目录

    bin存放了Java的操作工具,比如编译工具javac.启动JVM的Java等 db存放了Java测试的数据库Derby,企业不用 include存放C++的头文件 jre运行环境,里面有JVM li ...

  7. Gson的基本使用方法(google)

    原文:http://www.jianshu.com/p/e740196225a4 原作者:怪盗kidou 依赖包配置: <dependency> <groupId>com.go ...

  8. Struts2(三)——数据在框架中的数据流转问题

    一款软件,无在乎对数据的处理.而B/S软件,一般都是用户通过浏览器客户端输入数据,传递到服务器,服务器进行相关处理,然后返回到指定的页面,进行相关显示,完成相关功能.这篇博客重点简述一下Struts2 ...

  9. Alter的用法(添加字段,删除字段,修改字段名)

    1.在表emp中新增字段sexy(性别) alter table emp add sexy varchar2(2); 新增多个字段cxx 和shoneworn alter table emp add  ...

  10. Javascript进阶篇——(函数)笔记整理

    这节是根据慕课网和JavaScript DOM编程艺术一书加起来做的笔记 什么是函数如果需要多次使用同一段代码,可以把它们封装成一个函数.函数(function)就是一组允许在你的代码里随时调用的语句 ...