Android 自定义dialog(AlertDialog的修改样式)
LayoutInflater inflater = LayoutInflater(AudioActivity.this);
View timepickerview = inflater.inflate(R.layout.timepicker, null);
final Dialog loading = new Dialog(context, R.style.customstyle);//设置样式
loading.setCancelable(false);//点击屏幕不可消失
loading.show();//必须写在setContentView前面
int number = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, AudioActivity.this.getResources().getDisplayMetrics());
loading.setContentView(timepickerview,new RelativeLayout.LayoutParams(number*30, number*18));
Button positiveButton = (Button) timepickerview.findViewById(R.id.positiveButton);//确定按钮
Button negativeButton = (Button) timepickerview.findViewById(R.id.negativeButton);//取消按钮
positiveButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
}
});
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/timePicker1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical" > <LinearLayout
android:id="@+id/wheelview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=""
android:orientation="horizontal" > <com.mogunote.time.WheelView
android:id="@+id/year"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="" /> <com.mogunote.time.WheelView
android:id="@+id/month"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="" /> <com.mogunote.time.WheelView
android:id="@+id/day"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="" /> <com.mogunote.time.WheelView
android:id="@+id/hour"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="" /> <com.mogunote.time.WheelView
android:id="@+id/min"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="" /> <com.mogunote.time.WheelView
android:id="@+id/sec"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="" />
</LinearLayout> <RelativeLayout
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="@id/wheelview"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" > <TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:text="@string/alarm"
android:textColor="@android:color/white"
android:textSize="18dip" /> <ToggleButton
android:id="@+id/toggle_AutoPlay"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/tv"
android:background="@drawable/btn_toggle"
android:gravity="left|center_vertical"
android:textOff=""
android:textOn="" />
</RelativeLayout> <View
android:layout_width="fill_parent"
android:layout_height="1px"
android:background="@color/gray"/> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal" > <Button
android:id="@+id/positiveButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginTop="3dip"
android:text="确定"
android:background="@color/white"
android:textColor="@color/blue"
android:layout_weight=""
android:singleLine="true" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@color/gray"
/>
<Button
android:id="@+id/negativeButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginTop="3dip"
android:text="取消"
android:background="@color/white"
android:textColor="@color/blue"
android:layout_weight=""
android:singleLine="true" />
</LinearLayout> </LinearLayout>
Android 自定义dialog(AlertDialog的修改样式)的更多相关文章
- Android自定义 Dialog 对话框
Android自定义Dialoghttp://www.cnblogs.com/and_he/archive/2011/09/16/2178716.html Android使用自定义AlertDialo ...
- Android创建自定义dialog方法详解-样式去掉阴影效果
在自定义组件时,从已有组件源码中会很大收获.就拿progressDialog来说 间接父类是dialog,想了解dialog继承结构可以去百度,或者 从构造器来说ProgressDial ...
- android 自定义Dialog背景透明及显示位置设置
先贴一下显示效果图,仅作参考: 代码如下: 1.自定义Dialog public class SelectDialog extends AlertDialog{ public SelectDialog ...
- Android自定义Dialog
Android开发过程中,常常会遇到一些需求场景——在界面上弹出一个弹框,对用户进行提醒并让用户进行某些选择性的操作, 如退出登录时的弹窗,让用户选择“退出”还是“取消”等操作. Android系统提 ...
- android 自定义Dialog去除黑色边框
在自定义Dialog时显示的界面中老是有黑色的边框,下面就介绍使用style去除黑色边框方法. 首先在values/styles定义自定义样式: <style name="MyDial ...
- Android自定义Dialog及其布局
实际项目开发中默认的Dialog样式无法满足需求,需要自定义Dialog及其布局,并响应布局中控件的事件. 上效果图: 自定义Dialog,LogoutDialog: 要将自定义布局传入构造函数中, ...
- Android—自定义Dialog
在 Android 日常的开发中,Dialog 使用是比较广泛的.无论是提示一个提示语,还是确认信息,还是有一定交互的(弹出验证码,输入账号密码登录等等)对话框. 而我们去看一下原生的对话框,虽然随着 ...
- Android自定义Dialog(美化界面)
前言:在做项目的时候,发现dialog界面太丑陋,从csdn上下载了一份自定义dialog的源码,在他的基础上对界面进行美化...有需要的朋友可以直接拿走 效果图如下: 主要代码: /** * 自定义 ...
- Android 自定义Dialog类,并在Activity中实现按钮监听。
实际开发中,经常会用到Dialog,比如退出时候会弹出是否退出,或者还有一些编辑框也会用Dialog实现,效果图如下: 开发中遇到的问题无非在于如果在Activity中监听这个Dialog中实现的 ...
随机推荐
- JavaScript与html5写的贪吃蛇完整代码
JavaScript与html5写的贪吃蛇完整代码 查看运行效果可访问http://www.codesocang.com/texiao/youxitexiao/2014/0402/7045.html# ...
- mac os 终端提示 you have new mail
这里的信息可能是由于所做的什么操作触发了发邮件的事件, 系统发送的邮件提醒. 我遇到的原因是由于运行 cron , 由于权限所导致了发邮件的事件提醒. Last login: Tue Apr 26 0 ...
- 通过扫描包路径获取包内class
public static Set<Class<?>> getClasses(ClassLoader classLoader, String pack) { Set<Cl ...
- UESTCOJ-BiliBili, ACFun… And More!(水题)
BiliBili, ACFun… And More! Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Ja ...
- div a块状布局
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- innosetup 安装静默安装msi,指定安装路径的方法
自己看了很久帮助,分号的用法确实不太好用,湿了这个东东估计很多人会用到,发出来给大家参考. Filename: "{app}/msiexec.exe";Parameters: &q ...
- 搭建linux环境下jenkins可移植环境
1:背景 项目领域:android. 项目需求为:建立一个网站用于产品经理(以下称为PM)配置该apk所需服务插件,打包出包(包含:apk,文档,demo等等)给厂商并且记录打包出包等信息. 项目设计 ...
- asp.net <%%> <%#%><%=%><%@%><%$%>用法与区别
1.<% %>用来绑定后台代码 如: < % for(int i=0;i<100;i++) { Reaponse.Write(i.ToString()); } %> 2. ...
- C# 虚方法 抽象方法 接口
虚方法:virtu 注意的几点: 1,父类中如果有方法让子类重写,则可以将该方法标记为virtual 2.虚方法在父类中必须有实现,哪怕是空实现 3虚方法子类可以重写,也可以不重写 4.如果类是抽象类 ...
- (一)跟我一起玩Linux网络服务:DNS服务——BIND(/etc/named.conf、/var/named)设置实现和解释
2015年3月24更新 添加了要加的配置域名解析器(否则会找不到域名) 一.创建该实验的的模型 配置完gate虚拟机的两张网卡后,就启动gate的转发 [root@localhost ro ...