- 浏览: 3587417 次
- 性别:
- 来自: 杭州
-
文章分类
- 全部博客 (1491)
- Hibernate (28)
- spring (37)
- struts2 (19)
- jsp (12)
- servlet (2)
- mysql (24)
- tomcat (3)
- weblogic (1)
- ajax (36)
- jquery (47)
- html (43)
- JS (32)
- ibatis (0)
- DWR (3)
- EXTJS (43)
- Linux (15)
- Maven (3)
- python (8)
- 其他 (8)
- JAVASE (6)
- java javase string (0)
- JAVA 语法 (3)
- juddiv3 (15)
- Mule (1)
- jquery easyui (2)
- mule esb (1)
- java (644)
- log4j (4)
- weka (12)
- android (257)
- web services (4)
- PHP (1)
- 算法 (18)
- 数据结构 算法 (7)
- 数据挖掘 (4)
- 期刊 (6)
- 面试 (5)
- C++ (1)
- 论文 (10)
- 工作 (1)
- 数据结构 (6)
- JAVA配置 (1)
- JAVA垃圾回收 (2)
- SVM (13)
- web st (1)
- jvm (7)
- weka libsvm (1)
- weka屈伟 (1)
- job (2)
- 排序 算法 面试 (3)
- spss (2)
- 搜索引擎 (6)
- java 爬虫 (6)
- 分布式 (1)
- data ming (1)
- eclipse (6)
- 正则表达式 (1)
- 分词器 (2)
- 张孝祥 (1)
- solr (3)
- nutch (1)
- 爬虫 (4)
- lucene (3)
- 狗日的腾讯 (1)
- 我的收藏网址 (13)
- 网络 (1)
- java 数据结构 (22)
- ACM (7)
- jboss (0)
- 大纸 (10)
- maven2 (0)
- elipse (0)
- SVN使用 (2)
- office (1)
- .net (14)
- extjs4 (2)
- zhaopin (0)
- C (2)
- spring mvc (5)
- JPA (9)
- iphone (3)
- css (3)
- 前端框架 (2)
- jui (1)
- dwz (1)
- joomla (1)
- im (1)
- web (2)
- 1 (0)
- 移动UI (1)
- java (1)
- jsoup (1)
- 管理模板 (2)
- javajava (1)
- kali (7)
- 单片机 (1)
- 嵌入式 (1)
- mybatis (2)
- layui (7)
- asp (12)
- asp.net (1)
- sql (1)
- c# (4)
- andorid (1)
- 地价 (1)
- yihuo (1)
- oracle (1)
最新评论
-
endual:
https://blog.csdn.net/chenxbxh2 ...
IE6 bug -
ice86rain:
你好,ES跑起来了吗?我的在tomcat启动时卡在这里Hibe ...
ES架构技术介绍 -
TopLongMan:
...
java public ,protect,friendly,private的方法权限(转) -
贝塔ZQ:
java实现操作word中的表格内容,用插件实现的话,可以试试 ...
java 读取 doc poi读取word中的表格(转) -
ysj570440569:
Maven多模块spring + springMVC + JP ...
Spring+SpringMVC+JPA
很多时候,我们需要一个自定义的对话框,这个对话框最好是由一个layout.xml的自己设计,
不是由代码敲出来的,这里记录下简单的自定义的对话框。
首先创建一个android工程:
在MainActivity中
package endual.main;
import android.app.Activity;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.os.Bundle;
public class MianActivity extends Activity implements
android.view.View.OnClickListener {
Button btn1 = null;
Button btn2 = null;
Button btn3 = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn1 = (Button) findViewById(R.id.b1);
btn2 = (Button) findViewById(R.id.b2);
btn3 = (Button) findViewById(R.id.b3);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.b1:
break;
case R.id.b2:
case R.id.b3:
new MyDialogs(this).setDisplay();
break;
default:
}
}
// 自定义对话框
class MyDialogs extends Dialog implements android.view.View.OnClickListener {
private Button b1;
private Window window = null;
public MyDialogs(Context context) {
super(context);
}
public void setDisplay() {
setContentView(R.layout.dialog);// 设置对话框的布局
b1 = (Button) findViewById(R.id.clo);
b1.setOnClickListener(this);
setProperty();
setTitle("自定义对话框");// 设定对话框的标题
show();// 显示对话框
}
// 要显示这个对话框,只要创建该类对象.然后调用该函数即可.
public void setProperty() {
window = getWindow();// 得到对话框的窗口.
WindowManager.LayoutParams wl = window.getAttributes();
wl.x = 0;// 这两句设置了对话框的位置.0为中间
wl.y = 180;
wl.alpha = 0.6f;// 这句设置了对话框的透明度
wl.gravity = Gravity.BOTTOM;
window.setAttributes(wl);
}
@Override
public void onClick(View v) {
dismiss();// 取消
}
}
}
创建两个布局文件
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:id="@+id/b1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1" />
<Button
android:id="@+id/b2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2" />
<Button
android:id="@+id/b3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3" />
<Button
android:id="@+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
------------------------------------------------------------------
dialog.xml 这个是由我们自己定义的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android1:layout_width="400px"
android1:layout_height="81dp"
android1:gravity="center"
android1:text="xxxxxxxxxxxxxxxxxxxxxxxx/nnxxxxxxxxxxxxxxxxxx" />
<RadioGroup
android1:id="@+id/radioGroup1"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content" >
<RadioButton
android1:id="@+id/radio0"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:checked="true"
android1:text="RadioButton" />
<RadioButton
android1:id="@+id/radio1"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:text="RadioButton" />
<RadioButton
android1:id="@+id/radio2"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:text="RadioButton" />
</RadioGroup>
<Button
android:id="@+id/clo"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
------------------------------------------
好了,简单的自定义的dialog就创建好,网上还有许多类似的题材,这个demo也是根据人家的资料修改的。
不是由代码敲出来的,这里记录下简单的自定义的对话框。
首先创建一个android工程:
在MainActivity中
package endual.main;
import android.app.Activity;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.os.Bundle;
public class MianActivity extends Activity implements
android.view.View.OnClickListener {
Button btn1 = null;
Button btn2 = null;
Button btn3 = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn1 = (Button) findViewById(R.id.b1);
btn2 = (Button) findViewById(R.id.b2);
btn3 = (Button) findViewById(R.id.b3);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.b1:
break;
case R.id.b2:
case R.id.b3:
new MyDialogs(this).setDisplay();
break;
default:
}
}
// 自定义对话框
class MyDialogs extends Dialog implements android.view.View.OnClickListener {
private Button b1;
private Window window = null;
public MyDialogs(Context context) {
super(context);
}
public void setDisplay() {
setContentView(R.layout.dialog);// 设置对话框的布局
b1 = (Button) findViewById(R.id.clo);
b1.setOnClickListener(this);
setProperty();
setTitle("自定义对话框");// 设定对话框的标题
show();// 显示对话框
}
// 要显示这个对话框,只要创建该类对象.然后调用该函数即可.
public void setProperty() {
window = getWindow();// 得到对话框的窗口.
WindowManager.LayoutParams wl = window.getAttributes();
wl.x = 0;// 这两句设置了对话框的位置.0为中间
wl.y = 180;
wl.alpha = 0.6f;// 这句设置了对话框的透明度
wl.gravity = Gravity.BOTTOM;
window.setAttributes(wl);
}
@Override
public void onClick(View v) {
dismiss();// 取消
}
}
}
创建两个布局文件
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:id="@+id/b1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1" />
<Button
android:id="@+id/b2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2" />
<Button
android:id="@+id/b3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button3" />
<Button
android:id="@+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
------------------------------------------------------------------
dialog.xml 这个是由我们自己定义的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android1:layout_width="400px"
android1:layout_height="81dp"
android1:gravity="center"
android1:text="xxxxxxxxxxxxxxxxxxxxxxxx/nnxxxxxxxxxxxxxxxxxx" />
<RadioGroup
android1:id="@+id/radioGroup1"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content" >
<RadioButton
android1:id="@+id/radio0"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:checked="true"
android1:text="RadioButton" />
<RadioButton
android1:id="@+id/radio1"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:text="RadioButton" />
<RadioButton
android1:id="@+id/radio2"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content"
android1:text="RadioButton" />
</RadioGroup>
<Button
android:id="@+id/clo"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
------------------------------------------
好了,简单的自定义的dialog就创建好,网上还有许多类似的题材,这个demo也是根据人家的资料修改的。
发表评论
-
android离线
2019-11-04 21:25 311https://www.jianshu.com/p/fdfc4 ... -
android 异步更新
2015-07-11 22:42 1512http://www.apkbus.com/forum.php ... -
仿微米
2015-06-26 10:22 0http://www.javaapk.com/source/4 ... -
仿微信
2015-06-26 10:21 1930http://www.javaapk.com/source/1 ... -
网易客户端
2015-06-26 10:20 1613http://www.javaapk.com/source/4 ... -
仿朋友圈
2015-06-26 10:18 1713http://www.javaapk.com/source/8 ... -
仿朋友圈
2015-06-26 10:13 1847http://www.eoeandroid.com/threa ... -
全国ABC查询
2015-06-26 10:07 1391IM 功能 环信云 信息统计 Umeng 分享Umeng 更新 ... -
android 判断网络
2015-06-25 16:00 1281http://www.cnblogs.com/renqingp ... -
android 多彩表格
2015-05-31 16:06 1488http://blog.csdn.net/conowen/ar ... -
android socket
2015-05-31 16:01 1656http://blog.csdn.net/conowen/ar ... -
微信播放语音3
2015-02-25 12:00 1447http://download.csdn.net/detail ... -
微信语音播放2
2015-02-25 11:57 1384http://download.csdn.net/detail ... -
微信语音播放
2015-02-25 11:56 1732http://www.apkbus.com/android-1 ... -
超强的资料整合
2015-01-05 11:04 1235http://zz563143188.iteye.com/bl ... -
最强开发资源平台大合集
2015-01-04 14:50 1897程序员代码应用开发平 ... -
Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
2014-09-04 15:45 1390http://blog.csdn.net/vipzjyno1/ ... -
android应用推广
2014-09-03 23:25 1326应用推广不必愁,有米 ... -
android 图片异步加载
2014-09-03 16:47 1141http://www.csdn.net/article/201 ... -
android hander的使用
2014-09-02 23:46 1372http://www.cnblogs.com/xiaoran1 ...
相关推荐
总的来说,创建Android自定义对话框需要理解DialogFragment或AlertDialog.Builder的工作原理,以及如何将它们与自定义布局相结合。通过`defineDialog`这样的示例,开发者可以学习到如何从头开始构建一个具有特定功能...
本资源“安卓Android源码——android 自定义对话框.rar”显然包含了关于如何在Android平台上创建和定制对话框的源代码示例。通过这个压缩包,我们可以学习到如何摆脱系统默认样式,设计出更符合应用风格的对话框。 ...
在Android开发中,自定义对话框...通过以上步骤,我们成功地实现了Android自定义对话框,模拟了QQ退出界面的效果。在实际应用中,可以根据项目需求对这个对话框进行进一步的定制和优化,以提供更加个性化的用户体验。
总之,Android自定义对话框Dialog的界面美化是一个涉及布局设计、样式定制、事件处理等多个方面的过程。通过深入理解并实践这些技术,开发者可以创造出更具吸引力和个性化的Dialog,从而提高用户对应用的满意度。
在Android开发中,自定义对话框(Custom Dialog)是一个重要的组件,它允许开发者根据应用程序的UI风格和功能需求创建独特且交互性强的弹出界面。本压缩包中的资源提供了关于如何在Android应用中实现自定义对话框的...
一般自定义对话框有三种办法: 1、重写Dialog来实现。 2、获取Dialog的Window对象实现。 3、使用WindowManager来实现。 4、使用DialogTheme来实现。 详细请看:...
在Android开发中,自定义对话框(Dialog)是常见的需求,它可以为用户提供更丰富的交互体验。自定义对话框可以按照应用程序的设计风格进行定制,包括布局、颜色、按钮样式等,从而提升应用的用户体验。本篇将围绕...
下面将详细介绍Android自定义对话框的相关知识点。 首先,Android中的对话框通常是通过`Dialog`类或其子类如`AlertDialog`来创建的。`Dialog`继承自`Activity`,而`AlertDialog`则是`Dialog`的一个更具体的实现,常...
在Android开发中,自定义对话框(Custom Dialog)是一种常用的技术,它允许开发者根据应用的UI风格和功能需求创建个性化的对话框。本教程将详细讲解如何在Android中实现自定义对话框,并提供代码示例。 一、Android...
在Android开发中,自定义对话框...综上所述,Android自定义对话框结合动画的应用不仅能够丰富用户体验,还能增强应用的美观度。通过合理的布局设计和动画设置,开发者可以创造出功能强大且具有吸引力的对话框组件。
本资源"安卓Android源码——android 自定义对话框.zip"包含了实现自定义对话框的源代码,这对于理解和实践Android应用的界面定制具有重要意义。 首先,我们要理解Android系统提供的默认对话框类`AlertDialog`和`...
这篇博客文章“Android自定义对话框的使用”深入探讨了如何在Android项目中创建和使用自定义对话框。 首先,我们了解自定义对话框的基本概念。对话框(Dialog)是Android中的一个窗口,它浮于应用程序之上,用于向...
在Android应用开发中,自定义...通过这个示例项目,你可以深入理解Android自定义对话框的实现原理,以及如何在实际项目中应用。同时,也可以借此机会提高对Android源码阅读和分析的能力,进一步提升你的开发技能。
通过研究这个项目,你可以更好地理解和掌握Android自定义对话框的实践技巧,从而在自己的项目中灵活运用。无论是学生的学习、个人的技能提升还是公司的项目开发,这个源码都是一个很好的参考资料。
在Android开发中,自定义对话框(Custom Dialog)是一个重要的组件,它允许开发者根据应用程序的UI风格和功能需求创建独特且具有交互性的弹出窗口。本资料“安卓开发-android 自定义对话框.zip”可能包含一系列关于...
在Android开发中,自定义对话框(Custom Dialog)是一种常见的用户界面组件,它允许开发者根据应用的风格和需求创建独特的提示或交互界面。本篇将深入探讨如何在Android中实现自定义对话框,并通过示例代码`MyDialog...