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. 客户端HttpClient处理 Servlet Gzip

    服务端采用gzip对文本内容进行压缩处理,客户端使用HttpClient获取数据并进行gzip解压缩. 一: 服务端 public class GzipTestServlet extends Http ...

  2. js Array数组的使用

    js Array数组的使用   Array是javascript中的一个事先定义好的对象(也可以称作一个类),可以直接使用 创建Array对象 var array=new Array(): 创建指定元 ...

  3. 如何清空android ListView控件的内容

    第一种方法: listView.setAdapter(null); 第二种方法: listAdapter.clear(); listAdapter.notifyDataSetChanged() ; 满 ...

  4. 在Linux CentOS 6.5 (Final)上安装git-1.9.0

    CentOS 6.5 (Final)默认安装的git版本为1.7.1.3,而我们希望安装1.9.0版本.由于rpm安装库里没有1.9.0版本,因此我们需要找其它方法来安装. 网上有很多文章介绍了如何从 ...

  5. Unix命令行学习

    Listing files and directories ls 显示你当前目录的文件 ls -a 显示你千亩目录的文件(包括隐藏文件)ls <name1>/<name2> 显 ...

  6. Java程序员面试题集(136-150)(转)

    转:http://blog.csdn.net/jackfrued/article/details/17740651 Java程序员面试题集(136-150) 摘要:这一部分主要是数据结构和算法相关的面 ...

  7. poj1426 Find The Multiple

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14622   Accepted: 593 ...

  8. Cocos2d-x游戏开发CCBAnimationManager控制动画

    CocosBuilder能方便的编辑各种动画.大部分动画都是以独立片段的形式存在的. 须要由程序来控制何时播放. 管理ccbi文件的动画播放有个专门的类:CCBAnimationManager 大致的 ...

  9. Android_Fragment_Fragment具体解释

    Android_Fragment_Fragment具体解释 分类: Android基础2013-10-03 08:23 92人阅读 评论(0) 收藏 举报 AndroidFragmentFragmen ...

  10. Oracle SQL函数之转换函数To_char汇总

    TO_CHAR(x[[,c2],C3])[功能]将日期或数据转换为char数据类型[参数]x是一个date或number数据类型.c2为格式参数c3为NLS设置参数如果x为日期nlsparm=NLS_ ...