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 ...
随机推荐
- javascript string对象的属性与方法
一 创建string对象 new string('string'); 更直接的定义方法是var str = 'string'; 二 string属性 1.constructor 2.lenght 字符 ...
- Ext4 MVC CRUD操作
项目目录结构如下: (1)index.html <!DOCTYPE html> <html> <head> <title>用户管理</title& ...
- Codeforces 494B Obsessive String
http://www.codeforces.com/problemset/problem/494/B 题意:给出两个串S,T,求有几种将S分成若干个子串,满足T都是这若干个子串的子串. 思路:f[n] ...
- Asp.net 处理程序(第五篇)
HttpApplication有19个标准事件,当到达第8个事件PostMapRequestHandler触发的时候,标志着已经获取到了处理请求的处理程序对象,在第11个事件PreRequestHan ...
- XmlDocument,XDocument相互转换
XmlDocument,XDocument相互转换 using System; using System.Xml; using System.Xml.Linq; namespace MyTest { ...
- Calendar中add函数和roll函数的用法及区别
Calendar中add()和roll()函数的用法一.取某个时间点后的整点时刻.例如1984年7月7日15:23:05后的整点时刻即为1984-07-07 16:00:00.实现如下:Calenda ...
- java中spring提供的属性copy方法
BeanUtils.copyProperties(source, target); 今天用到属性的copy方法
- Can you find it? 分类: 二分查找 2015-06-10 19:55 5人阅读 评论(0) 收藏
Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t ...
- apache http配置https
<一,Lamp系统搭建> yum install httpd httpd-devel mysql mysql-server mysql-devel php php-mysql php-co ...
- JNI与JNA性能比较
JNI与JNA性能比较 在介绍JNA时,提到了JNA是基于JNI的,是在JNI上封装了一层,JNI性能不如JNA.最近在网上看到篇简单的比较这两者性能的文档,感觉不错,现转载一下: 分别用JNI和JN ...