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. Windows中安装Emacs

    首先从http://gnu.org/software/emacs中下载window下的压缩包,然后解压..运行ROOT/bin/addpm.exe进行安装. 将鼠标右键添加Emacs编辑: 1. 打开 ...

  2. 嵌入式设备web服务器

    操作系统:ubuntu10.04 前言:    为了提高对设备的易操作性,很多设备中提供pc机直接通过浏览器操作设备的功能.这就需要在设备中实现web服务器.    现在在嵌入式设备中所使用的web服 ...

  3. (转)ZOJ 3687 The Review Plan I(禁为排列)

    The Review Plan I Time Limit: 5 Seconds      Memory Limit: 65536 KB Michael takes the Discrete Mathe ...

  4. FVANCOP/ChartNew.js

    FVANCOP/ChartNew.js FVANCOP/ChartNew.js

  5. magento添加系统sections配置时应注意的事项

    (1)只有在新增sections是需要增加对应的acl配置,这个配置可以放在config.xml中或者放在adminhtml.xml中 <adminhtml> <acl> &l ...

  6. Eclipse文件覆盖问题

    window-preferences-General-Search找到第一行的一个选项 Reuse editors to show matches他的意思是说在同一个编辑里面显示匹配的文件,如果后面有 ...

  7. DataReader、Table、DataSet和Entity相互转化

    public class CommonService { #region DataReader转化 /// <summary> /// 将DataReader转化为Table /// &l ...

  8. paip.c++ qt 目录遍历以及文件操作

    paip.c++ qt 目录遍历以及文件操作 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net/a ...

  9. Swift观察者模式

    用swift写一个观察者模式,集合了swift语言中类,数组,协议,方法,字符串,条件控制语句等一些语法.简单介绍下观察者模式,在观察者模式中,会改变的是主题的状态以及观察者的数目.用这个模式,可以改 ...

  10. Android应用程序与SurfaceFlinger服务的关系概述和学习计划

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/7846923 SurfaceFlinger服务负 ...