android 自定义AlertDialog(一段)
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(一段)的更多相关文章
- Android 自定义AlertDialog退出对话框
Android 自定义AlertDialog退出对话框 转 https://blog.csdn.net/wkh11/article/details/53081634在项目中很多时候会出现点击返回键出现 ...
- Android 自定义AlertDialog的实现
Android默认的AlertDialog太单调,我们可以通过继承原生的Dialog来实现自定义的Dialog. 本文的自定义Dialog和原生的AlertDialog的创建方式类似,通过一个静态Bu ...
- Android自定义AlertDialog
常见的一种方法: [html] view plaincopyprint? AlertDialog.Builder builder; AlertDialog alertDialog; LayoutInf ...
- Android 自定义AlertDialog(退出提示框)
有时候我们需要在游戏或应用中用一些符合我们样式的提示框(AlertDialog) 以下是我在开发一个小游戏中总结出来的.希望对大家有用. 先上效果图: 下面是用到的背景图或按钮的图片 经过查找资料和参 ...
- Android 自定义AlertDialog的写法和弹出软键盘和覆盖状态栏
private void showMyDialog(int layoutId){ AlertDialog myDialog = new AlertDialog.Builder(context).cre ...
- android 自定义alertdialog和取消dialog
看代码: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle ...
- android 自定义AlertDialog
xml: alter_dialog_two <?xml version="1.0" encoding="utf-8"?> <LinearLay ...
- Android之自定义AlertDialog和PopupWindow实现(仿微信Dialog)
我们知道,在很多时候,我们都不用Android内置的一些控件,而是自己自定义一些自己想要的控件,这样显得界面更美观. 今天主要是讲自定义AlertDialog和popupWindow的使用,在很多需求 ...
- Xamarin.Android 记事本(二)自定义AlertDialog
导读 1.自定义一个AlertDialog 2.添加一条数据 正文 记事本应当有一个添加功能,这里我打算在右上角放一个item,然后点击这个item弹出一个对话框,输入名称,点击确定跳转到另一个act ...
随机推荐
- SQL查询 addScalar()或addEntity()
Hibernate除了支持HQL查询外,还支持原生SQL查询. 对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行Session.createSQLQuery()获取这个接口.该 ...
- asm_c515c.uew
/L20"ASM for C515C" Nocase Line Comment = ; String Chars = "' DisableMLS File Extensi ...
- plsql在64位机器下读取tnsname.ora 及oracle_home异常的解决办法
问题是: 我在自己电脑(win7 64bit)上安装了oracle的64位数据库 通过sqlplus能正常连接 主要是安装pl/sql时 我是这样安装的1.在网上下载了个instantcli ...
- Webix快速跨浏览器的JavaScript UI组件
网址:http://webix.com/ 寥寥几行代码就将页面渲染出来了,确实值得一试!
- 查看linux系统的开机时间/重启历史记录
查看linux系统的开机时间/重启历史记录1.who -b命令[root@rusky opt]# who -b ---查看最后一次(上次)系统启动的时间 system boot Dec 27 05:0 ...
- Winform单例模式与传值
单例模式(singleton)的意思就是只有一个实例.单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例.这个类称为单例类. 在多窗体界面中,如果要加入一个“关于”的窗体,用于显 ...
- resolv.conf 是什么
From Wikipedia, the free encyclopedia This article does not cite any references or sources. Please h ...
- MVC调试异常--未能将脚本调试器附加到计算机
32位机: 解决办法:以管理员身份打开CMD,运行:regsvr32.exe "%ProgramFiles(x86)%\Common Files\Microsoft Shared\VS7De ...
- Java-----判断是否为基本类型
转载自:http://blog.csdn.net/hekewangzi/article/details/51969774
- python 学习之爬虫练习
通过学习python,写两个简单的爬虫,没用线程,本地抓取速度还不错,有些瑕疵就是抓的图片有些显示不出来,代码做个笔记记录下: # -*- coding:utf-8 -*- import re imp ...