- 浏览: 426902 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
yehuiyan8002:
支持中文查询
快熟查找联系人 -
lehehe:
现成的接口,免费试用,http://www.haoservic ...
天气Widget -
D.Z:
android:focusable="false&q ...
CheckBox在ListView 而导致其OnItemClickListener不会被触发 -
freecode:
碰到该问题,CheckBox的android:focusabl ...
CheckBox在ListView 而导致其OnItemClickListener不会被触发 -
echohfut:
哥们,新博客是不是在墙外啊?不能访问。还有你怎么进行博客迁移的 ...
博客 迁移
自定义 Dialog
[功能]
android 提供给我们的只有2种Dialog 即 AlertDialog & ProgressDialog 但是 Dialog 有其自身的特点:1. 不是 Activity 2. 开销比 Activity 小得多
鉴于以上的优点 我们就有定制自己Dialog 的需求
[原理]
1. android 系统提供了一个class: Dialog. 而且你可以把自己的工作放在"protected void onCreate(Bundle savedInstanceState)" 在里面先调用系统的"super.onCreate(savedInstanceState)" 其就会保证调用这个method.
2. 至于 Dialog 界面的定制 可以写一个xml 文件 然后 在 "void onCreate(Bundle)" 通过 "setContentView()" 来使之生效
3. Dialog 使用问题: 1. 弹出:show() 2. 取消:dismiss()
[代码]
1. 创建一个 Dialog .
2. Dialog 的使用:
3. Dialog 的界面定制.
done!
[功能]
android 提供给我们的只有2种Dialog 即 AlertDialog & ProgressDialog 但是 Dialog 有其自身的特点:1. 不是 Activity 2. 开销比 Activity 小得多
鉴于以上的优点 我们就有定制自己Dialog 的需求
[原理]
1. android 系统提供了一个class: Dialog. 而且你可以把自己的工作放在"protected void onCreate(Bundle savedInstanceState)" 在里面先调用系统的"super.onCreate(savedInstanceState)" 其就会保证调用这个method.
2. 至于 Dialog 界面的定制 可以写一个xml 文件 然后 在 "void onCreate(Bundle)" 通过 "setContentView()" 来使之生效
3. Dialog 使用问题: 1. 弹出:show() 2. 取消:dismiss()
[代码]
1. 创建一个 Dialog .
public class CustomDialog extends Dialog { public CustomDialog(Context context) { super(context); // TODO Auto-generated constructor stub } protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.custom_dialog); setTitle("Custom Dialog"); TextView text = (TextView)findViewById(R.id.text); text.setText("Hello, this is a custom dialog!"); ImageView image = (ImageView)findViewById(R.id.image); image.setImageResource(R.drawable.sepurple); Button buttonYes = (Button) findViewById(R.id.button_yes); buttonYes.setHeight(5); buttonYes.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v) { // TODO Auto-generated method stub dismiss(); } }); Button buttonNo = (Button) findViewById(R.id.button_no); buttonNo.setSingleLine(true); buttonNo.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v) { // TODO Auto-generated method stub dismiss(); } }); } //called when this dialog is dismissed protected void onStop() { Log.d("TAG","+++++++++++++++++++++++++++"); } }
2. Dialog 的使用:
public class CustomDialogUsage extends Activity { CustomDialog cd; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); cd = new CustomDialog(this); Button buttonYes = (Button) findViewById(R.id.main_button); buttonYes.setOnClickListener(new OnClickListener(){ public void onClick(View v) { // TODO Auto-generated method stub cd.show(); } }); } }
3. Dialog 的界面定制.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_root" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" > <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="10dp" /> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5px" > <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="fill_parent" android:textColor="#FFF" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5px" > <Button android:id="@+id/button_yes" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" Yes " android:gravity="center" /> <Button android:id="@+id/button_no" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" No " android:gravity="center" /> </LinearLayout> </LinearLayout> </LinearLayout>
done!
- CustomDialogUsage.rar (90.2 KB)
- 下载次数: 1460
发表评论
-
滑动抽屉 另一种解决办法
2010-07-09 17:43 0滑动抽屉 -
Spinner 定制化 增强版
2010-07-09 14:34 2571Spinner 作为下拉选 ... -
ListView 内容之分批显示
2010-06-25 20:38 5861ListView 内容循环显示 大家试想 假如 ... -
MediaScanner 研究
2010-06-23 15:21 3104MediaScanner 之所以拿MediaSc ... -
CheckBox在ListView 而导致其OnItemClickListener不会被触发
2010-06-22 20:55 18878CheckBox在ListView 而导致其OnItemCli ... -
获取Launcher 启动列表
2010-06-22 10:09 3097获取Launcher 启动列表 即 列出所有Launc ... -
PreferenceActivity 全接触
2010-06-19 12:53 9389PreferenceActivity 为了引入 ... -
android src 下载 编译 安装 全接触
2010-06-12 14:44 0android src - download install ... -
Intent.createChooser() 妙用
2010-06-12 11:14 5917Intent.createChooser(ntent targ ... -
SMS管理:收信箱 发信息 编写新信息
2010-06-07 08:14 14364SMS管理 [功能] 1. 收信箱:显示 ... -
求 android 手机 帮忙测试sms服务系统 谢谢
2010-06-05 08:25 1409Hi guys, 最近一段时间没有更新blog 因为一 ... -
流媒体 播放 理论篇
2010-05-28 14:42 2122流媒体播放 之所以为理论篇 因为该篇仅实现了播放功能 ... -
NDK 搭建与HelloWorld
2010-05-19 09:48 3152NDK [前提] 1. Cygwin 用于安装 ... -
自定义字体
2010-05-15 10:49 1162自定义字体: []代码 步骤] 1 ... -
模糊查找 再深入
2010-05-15 09:41 3096模糊查找 再深入 应某位大哥要求 再次对 SQLite ... -
快捷方式Bar + ViewGroup - 自定义
2010-05-09 09:20 2380TabActivity - 自定义 其实 这篇感觉极鸡 ... -
View 拖动&插入 研究
2010-05-09 07:14 3928View 拖动&插入 即: ... -
带图标 快捷键 Menu - 终极版
2010-05-04 20:23 1784Menu 改头换面 扩展如下: 1. 图标化文字 2 ... -
*.gif 解码 - 实践
2010-05-02 18:58 1650*.gif decode 前面已经说过 今天不打算再说了 ... -
*.gif 解码 - 理论
2010-05-01 21:11 1484我们知道Android 默认是不支持*.gif 的 但是 ...
相关推荐
qml 用item自定义dialog 对话框 很好用的一个自定义对话框
android 自定义 dialog android 自定义 dialog android 自定义 dialog android 自定义 dialog
自定义dialog
最近用到类似苹果悬浮按钮这种非全屏显示的界面,于是第一想到的是利用自定义Dialog来实现,写了一个自定义Dialog的最简单的Demo。比较简单,易于学习。另有我的博客介绍 ...
继承AppCompatDialogFragment自定义dialog 弹框(带悬浮效果),ListView绑定商品信息和图片,点击商品图片添加购物车,弹出悬浮框,继承自AppCompatDialogFragment基类的自定义dialog 弹框。源码可直接调试。大家...
微信小程序自定义dialog极度简洁版 内容页自己定义
自定义dialog实现登录框自定义dialog实现登录框
android 仿小米自定义dialog,采用继承dialog方式实现,动画效果一流,不容错过。blog地址:http://blog.csdn.net/luck_apple/article/details/38464545
自定义dialog弹出框,通过shape和seleter自定义出自己想要的样式。还有弹出的动画,从不同方向弹出和效果。
自定义Dialog加ListView,没事写着玩的,希望跟大家一起学习进步
自定义Dialog对话框(实现类似微信分享对话框),里面有完整的代码实现过程及示例
自定义dialog安全键盘,键盘数字可随机!
android自定义Dialog的简单实现,具体实现可以查看博客:http://blog.csdn.net/qq_20785431/article/details/53396985
整理了常用的dialog 包括:single Choice Dialog Multiple choice Dialog Input Dialog Progress Dialog
有些朋友碰到过需要自定义dialog的情况,比如随着安卓应用要求的需要,改变dialog的边框和背景,本安卓源码例子即给你介绍了此作用
自定义对话框样式,以及对话框的加载动画,告别Android默认丑陋的对话框!
资源是关于仿ios风格的弹出dialog,还可以根据需求自己改。在此免费分享飞大家
一个自定义的dialog,7种动画效果。弹出你想要的自定义窗口!