- 浏览: 517385 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
tangyunliang:
大哥你太历害了谢谢
Android基于XMPP Smack Openfire开发IM【四】初步实现两个客户端通信 -
u013015029:
LZ,请问下,在// 添加消息到聊天窗口 , 这里获取Ed ...
Android基于XMPP Smack Openfire开发IM【四】初步实现两个客户端通信 -
endual:
怎么保持会话,我搞不懂啊
Android基于XMPP Smack Openfire开发IM【一】登录openfire服务器 -
donala_zq:
显示:[2013-11-30 11:50:36 - Andro ...
android-----------新浪微博 -
donala_zq:
哥,运行不了啊
android-----------新浪微博
程序运行效果图:
[img]
[/img]
main.xml
res/layout/test.xml
Activity:
[img]
[/img]
main.xml
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <ImageView android:src="@drawable/jay" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <Button android:id="@+id/button0" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="确定取消信息框"/> <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="多个按钮信息框"/> <Button android:id="@+id/button2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="列表框"/> <Button android:id="@+id/button3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="进度条框"/> <Button android:id="@+id/button4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="单项选择列表框"/> <Button android:id="@+id/button5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="多项选择列表框"/> <Button android:id="@+id/button6" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="自定义布局"/> <Button android:id="@+id/button7" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="读取进度框"/> </LinearLayout> </ScrollView>
res/layout/test.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="horizontal" android:id="@+id/dialog"> <LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="horizontal" android:id="@+id/dialogname"> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tvUserName" android:text="姓名:" /> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/etUserName" android:minWidth="200dip" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="horizontal" android:id="@+id/dialognum" android:layout_below="@+id/dialogname"> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tvPassWord" android:text="密码:" /> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/etPassWord" android:minWidth="200dip" /> </LinearLayout> </RelativeLayout>
Activity:
package cn.m15.list; import java.util.ArrayList; import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; /** * 无敌小胖胖 * 无敌小老虎 * 无敌小鸡鸡 * */ public class MainDialog extends Activity implements Runnable{ /**确定取消信息框 **/ private static final int DIALOG_0 = 1; /**多个按钮信息框 **/ private static final int DIALOG_1 = 2; /**列表框 **/ private static final int DIALOG_2 = 3; /**进度条框 **/ private static final int DIALOG_3 = 4; /**单项选择列表框 **/ private static final int DIALOG_4 = 5; /**多项选择列表框 **/ private static final int DIALOG_5 = 6; /**自定义布局 **/ private static final int DIALOG_6 = 7; /**读取进度框 **/ private static final int DIALOG_7 = 8; private static final int MAX_PROGRESS = 100; private ProgressDialog mProgressDialog = null; final String[] mItems = {"item0","item1","itme2","item3","itme4","item5","item6"}; int mSingleChoiceID = -1; ArrayList <Integer>MultiChoiceID = new ArrayList <Integer>(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button0 = (Button) findViewById(R.id.button0); button0.setOnClickListener(new OnClickListener() { public void onClick(View v) { CreatDialog(DIALOG_0); } }); Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() { public void onClick(View v) { CreatDialog(DIALOG_1); } }); Button button2 = (Button) findViewById(R.id.button2); button2.setOnClickListener(new OnClickListener() { public void onClick(View v) { CreatDialog(DIALOG_2); } }); Button button3 = (Button) findViewById(R.id.button3); button3.setOnClickListener(new OnClickListener() { public void onClick(View v) { CreatDialog(DIALOG_3); mProgressDialog.setProgress(0); } }); Button button4 = (Button) findViewById(R.id.button4); button4.setOnClickListener(new OnClickListener() { public void onClick(View v) { CreatDialog(DIALOG_4); } }); Button button5 = (Button) findViewById(R.id.button5); button5.setOnClickListener(new OnClickListener() { public void onClick(View v) { CreatDialog(DIALOG_5); } }); Button button6 = (Button) findViewById(R.id.button6); button6.setOnClickListener(new OnClickListener() { public void onClick(View v) { CreatDialog(DIALOG_6); } }); Button button7 = (Button) findViewById(R.id.button7); button7.setOnClickListener(new OnClickListener() { public void onClick(View v) { CreatDialog(DIALOG_7); } }); } public void CreatDialog(int id) { AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this); switch(id) { case DIALOG_0: builder.setIcon(R.drawable.icon); builder.setTitle("你确定要离开吗?"); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //这里添加点击确定后的逻辑 showDialog("你选择了确定"); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //这里添加点击确定后的逻辑 showDialog("你选择了取消"); } }); break; case DIALOG_1: builder.setIcon(R.drawable.icon); builder.setTitle("投票"); builder.setMessage("您认为什么样的内容能吸引您?"); builder.setPositiveButton("有趣味的", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { showDialog("你选择了有趣味的"); } }); builder.setNeutralButton("有思想的", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { showDialog("你选择了有思想的"); } }); builder.setNegativeButton("主题强的", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { showDialog("你选择了主题强的"); } }); break; case DIALOG_2: builder.setTitle("列表选择框"); builder.setItems(mItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //点击后弹出窗口选择了第几项 showDialog("你选择的id为" + which + " , " + mItems[which]); } }); break; case DIALOG_3: mProgressDialog = new ProgressDialog(MainDialog.this); mProgressDialog.setIcon(R.drawable.icon); mProgressDialog.setTitle("进度条窗口"); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setMax(MAX_PROGRESS); mProgressDialog.setButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //这里添加点击后的逻辑 } }); mProgressDialog.setButton2("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //这里添加点击后的逻辑 } }); mProgressDialog.show(); new Thread(this).start(); return; case DIALOG_4: mSingleChoiceID = -1; builder.setIcon(R.drawable.icon); builder.setTitle("单项选择"); builder.setSingleChoiceItems(mItems, 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mSingleChoiceID = whichButton; showDialog("你选择的id为" + whichButton + " , " + mItems[whichButton]); } }); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if(mSingleChoiceID > 0) { showDialog("你选择的是" + mSingleChoiceID); } } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); break; case DIALOG_5: MultiChoiceID.clear(); builder.setIcon(R.drawable.icon); builder.setTitle("多项选择"); builder.setMultiChoiceItems(mItems, new boolean[]{false, false, false, false, false, false, false}, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { if(isChecked) { MultiChoiceID.add(whichButton); showDialog("你选择的id为" + whichButton + " , " + mItems[whichButton]); }else { MultiChoiceID.remove(whichButton); } } }); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String str = ""; int size = MultiChoiceID.size(); for (int i = 0 ;i < size; i++) { str+= mItems[MultiChoiceID.get(i)] + ", "; } showDialog("你选择的是" + str); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); break; case DIALOG_6: LayoutInflater factory = LayoutInflater.from(this); final View textEntryView = factory.inflate(R.layout.test, null); builder.setIcon(R.drawable.icon); builder.setTitle("自定义输入框"); builder.setView(textEntryView); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { EditText userName = (EditText) textEntryView.findViewById(R.id.etUserName); EditText password = (EditText) textEntryView.findViewById(R.id.etPassWord); showDialog("姓名 :" + userName.getText().toString() + "密码:" + password.getText().toString() ); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); break; case DIALOG_7: mProgressDialog = new ProgressDialog(this); mProgressDialog.setTitle("读取ing"); mProgressDialog.setMessage("正在读取中请稍候"); mProgressDialog.setIndeterminate(true); mProgressDialog.setCancelable(true); mProgressDialog.show(); return; } builder.create().show(); } private void showDialog(String str) { new AlertDialog.Builder(MainDialog.this) .setMessage(str) .show(); } @Override public void run() { int Progress = 0; while(Progress < MAX_PROGRESS) { try { Thread.sleep(100); Progress++; mProgressDialog.incrementProgressBy(1); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
发表评论
-
Android中如何模拟一次点击(touch)事件
2014-05-06 10:41 0在Android中有时需要模拟某一个View的touch事件, ... -
Android程序Crash时的异常上报
2014-04-28 18:15 0http://blog.csdn.net/singwhatiw ... -
android程序中证书签名校验的方法
2014-04-28 17:58 1902android程序中证书签名校验的方法一 2013-02 ... -
MD5理解错了,哎
2014-03-17 14:14 0MD5只对数据加密是无法解密的,也就是说,你把100加密后,就 ... -
Android 获取网络时间
2014-03-12 11:42 2010Android 获取网络时间 在网上看到的最常见的方式有: ... -
SQLite清空表并将自增列归零
2014-03-05 18:02 1464SQLite清空表并将自增列归零 作者:Zhu Yanfeng ... -
Handler小看一下
2013-11-11 16:42 0android handler调用post方法还是阻塞 su ... -
Frame Animation小看一下
2013-10-12 16:30 721Demo运行效果图: 源码: -
动画小学一下
2013-10-12 16:14 692转自: http://www.eoeandroid.com/f ... -
Android 动画之ScaleAnimation应用详解
2013-10-12 15:49 958===============eoeAndroid社区推荐:= ... -
android开发中的一个工具类
2013-06-19 16:04 0package com.wanpu.login.dialog; ... -
android TextView怎么设置个别字体颜色并换行?
2013-06-20 09:25 1635(1)、TextView 设置个别字体颜色 TextView ... -
Android开发之文件下载,状态时显示下载进度,点击自动安装
2013-05-07 15:38 1367在进行软件升级时,需要进行文件下载,在这里实现自定义的文件下载 ... -
android中的状态保存
2013-04-07 14:21 933package com.zzl.call; import ... -
android动画基础:tween动画
2013-04-06 11:21 1180工程结构图: [img] [/img] 四个动画的xml ... -
面试中遇到的几个问题
2013-06-09 11:56 942SAX与DOM之间的区别 SAX ( ... -
Android获取其他包的Context实例,然后调用它的方法,反射!!!
2013-03-25 10:32 1159Android中有Context的概念,想必大家都知道。Con ... -
Android的内存机制和常见泄漏情形
2013-03-06 16:55 753一、 Android的内存机制 Android的程序由Ja ... -
JUnit测试小小demo
2013-03-06 16:37 1083运行效果图: [img] [/img] 项目结构图 ... -
android开发中的异常小工具
2013-03-04 15:53 861package com.zzl.tools; impor ...
相关推荐
android Dialog效果集合【全】
android dialog用法集合与举例
包括所有Android Dialog ,代码写的比较详细,希望能给大家带来帮助。
将Android中各种Dialog集合了一下,希望对新手Dialog的学习有所帮助
Android 对话框 dialog 集合 收集所有对话框事例
Android dialog的显示位置、弹出效果、返回键控制、外部点击事件控制
dialog窗口大集合,收集整理常用的dialog样式。
主要为大家分享了一个属于自己的Android对话框(Dialog)自定义集合,建立自己的Android对话框,感兴趣的小伙伴们可以参考一下
android对话框大集合 各种你需要的android对话框 单选,多选,列表,进度条的对话框
Android之GPS定位.zip Android之Wifi学习教程.rar Android之用PopupWindow实现弹出菜单.rar android写的google map api 应用.rar android在wifi下手机与电脑的socket通信.rar Android应用开发揭秘源码 .zip Android...
Android开发不得不收集的工具类集合, 工欲善其事必先利其器!Android开发过程经常需要用到各式各样的工具类,虽然大部分只需谷歌/百度一下就能找到;但是有时候急需使用却苦苦搜寻不到。于是给大家介绍一个github上...
Android开发人员不得不收集的工具类集合 | 支付宝支付 | 微信支付(统一下单) | 微信分享 | 一键集成UCrop选择圆形头像 | 一键集成二维码和条形码的扫描与生成 | 常用Dialog | WebView的封装可播放视频 | 仿斗鱼...
Android开发人员不得不收集的工具类集合 | 支付宝支付 | 微信支付(统一下单) | 微信分享 | Zip4j压缩(支持分卷压缩与加密) | 一键集成UCrop选择圆形头像 | 一键集成二维码和条形码的扫描与生成 | 常用Dialog | ...
Android例子源码强大的listview效果集合项目 Android例子源码模仿IOS音乐的可拖动导航栏功能 Android例子源码模仿安卓微信、云播雷达扫描动画效果 Android例子源码类似58同城的通过滑屏控制引导页 Android例子源码计...
介绍 学习Android开发的代码,基于AndroidStudio View_Demo是Android基础控件和布局,包括TextView,Edittext,ImageView,Button,RadioButton,Checkbox,ProgressBar和拖动条。 Adapter_Demo 是Adapter相关的代码...
Android开发人员不得不收集的工具类集合 | 支付宝支付 | 微信支付(统一下单) | 微信分享 | Zip4j压缩(支持分卷压缩与加密) | 一键集成UCrop选择圆形头像 | 一键集成二维码和条形码的扫描与生成 | 常用Dialog | ...
第三方lib集合 Android应用图标 Android系统日历 加解密 自定义View以及动画 弹幕 Android个人网站 Android日期相关 Android埋点 面试相关 Android Tablayout Flutter Android悬浮窗 Android视频 RecyclerView ...
工具类集合 MLog工具类 日期获取工具类 网络检查工具类 权限检查工具类 MD5工具类 日志保存工具类 SheetDialog 底部弹出框 LogcatHelper.getInstance(this).start(filePath); 开启保存日志 LogcatHelper....
支付宝支付 | 微信支付(统一下单) | 微信分享 | 一键集成UCrop选择圆形头像 | 一键集成二维码和条形码的扫描与生成 | 常用Dialog | WebView的封装可播放视频 | 仿斗鱼滑动验证码 | Toast封装 | 震动 | GPS | ...