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中实现的 ...
随机推荐
- 第二篇:web之前端之css
前端之css 前端之css 本节内容 css概述及引入 css选择器 css常用属性 1.css概述及引入 CSS概述 CSS是Cascading Style Sheets的简称,中文称为层叠样式 ...
- 还原或删除sql server 2008数据库时,经常烩出现: “因为数据库正在使用,所以无法获得对数据库的独占访问权”,终解决方案
还原或删除sql server 2008数据库时,经常烩出现: “因为数据库正在使用,所以无法获得对数据库的独占访问权”,终解决方案如下 关键SQL语句: ALTER DATABASE [dateba ...
- Big Data應用:以"玩家意見"之數據分析來探討何謂"健康型線上遊戲"(上)
首先,所有資料都可以從網路上找到,只是我做了一些分析與整理而已.純粹分享心得~~ 最近再做研究的時候我跟我的同事K先生在某次偶然的討論中發現了一件有趣的事情. [疑~~~~~~~新楓之谷的玩家人氣指數 ...
- js--小结①
- XML的基本操作
所有 XML 文档中的文本均会被解析器解析.只有 CDATA 区段(CDATA section)中的文本会被解析器忽略.CDATA 部分中的所有内容都会被解析器忽略.CDATA 部分由 "& ...
- C# - linq查询现有的DataTable
可以通过linq对现有的DataTable进行查询,并将结果拷贝至新的DataTable中例如: // Query the SalesOrderHeader table for orders plac ...
- MySQL execute dynamic sql script.
SET @sql = (SELECT IF( (SELECT COUNT(*) FROM usher_network_log ) > 1000000, "SELECT 0", ...
- 一看就懂ReactJS
现在最热门的前端框架有AngularJS.React.Bootstrap等.自从接触了ReactJS,ReactJs的虚拟DOM(Virtual DOM)和组件化的开发深深的吸引了我,下面来跟我一起领 ...
- java 优化
代码优化,一个很重要的课题.可能有些人觉得没用,一些细小的地方有什么好修改的,改与不改对于代码的运行效率有什么影响呢?这个问题我是这么考虑的,就像大海里面的鲸鱼一样,它吃一条小虾米有用吗?没用,但是, ...
- 解决SDK Manager无法更新问题
因为google被封了,导致Android SDK Manager无法更新,解决方案如下: 1.选择tools->options,跳出Settings页面 2.设置HTTP Proxy代理,设置 ...