2011年3月8日
摘要: Android平台下所提供的菜单大体上可分为三类:选项菜单、上下文菜单和子菜单。当Activity在前台运行时,如果用户按下手机上的Menu键,此时就会在屏幕低端弹出相应的选项菜单。但这个功能需要开发人员编程来实现的,如果在开发应用程序时没有实现该功能,那么程序运行时按下手机的meun键是不会起作用的。对于携带图标的选项菜单,每次最多只能显示6个,当菜单选项多于6个时,将只显示前5个和一个扩展菜单选项,点击扩展菜单选项将会弹出其余的菜单项。扩展菜单项中将不会显示图标,但是可以显示单选按钮和复选框。以下模拟选项菜单main.xml布局文件<?xml version="1.0&qu 阅读全文
posted @ 2011-03-08 19:38 Ruthless 阅读(14919) 评论(0) 推荐(1) 编辑
  2011年3月7日
摘要: //js获取项目根路径,如: http://localhost:8083/uimcardprjfunction getRootPath(){ //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp var curWwwPath=window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp var pathName=window.document.location.pathname; var pos=curWwwPath.indexOf(pathN 阅读全文
posted @ 2011-03-07 16:51 Ruthless 阅读(75656) 评论(0) 推荐(3) 编辑
  2011年3月5日
摘要: 本文出自http://wangstar.javaeye.com/blog/409115,感觉基础知识归纳得不错,就COPY下来方便查找。 动画效果编程基础--Android Animation 动画类型 Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面旋转动画效果 JavaCode中 AlphaAnimation 渐变透明度动画效果 ScaleAnimation 渐变尺寸伸缩动画效果 TranslateAnimation 画面转换位置移动动画效果 Rot 阅读全文
posted @ 2011-03-05 10:16 Ruthless 阅读(2280) 评论(1) 推荐(1) 编辑
  2011年3月3日
摘要: Gson是Google的一个开源项目,可以将Java对象转换成JSON,也可能将JSON转换成Java对象。Gson里最重要的对象有2个Gson 和GsonBuilder。Gson有2个最基本的方法1) toJson() – 转换java 对象到JSON2) fromJson() – 转换JSON到java对象注意使用Gson时记得添加第三方类库gson-1.6.jar main.xml布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=" 阅读全文
posted @ 2011-03-03 20:36 Ruthless 阅读(34614) 评论(0) 推荐(2) 编辑
摘要: 测试的tomcat为apache-tomcat-6.0.18 ,数据库为mysql和oracle。配置步骤如下:1、把数据库的JDBC驱动放入D:\apache-tomcat-6.0.18\lib目录下2、在D:\apache-tomcat-6.0.18\conf\web.xml文件中,将下面代码加入到web.xml中: <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/mysql</res-ref-name> <res-type 阅读全文
posted @ 2011-03-03 16:09 Ruthless 阅读(10237) 评论(1) 推荐(3) 编辑
  2011年3月2日
摘要: 模拟一个案例:把AppWidget添加到桌面后,点击AppWidget后AppWidget文本会轮回改变main.xml布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" 阅读全文
posted @ 2011-03-02 17:41 Ruthless 阅读(3999) 评论(0) 推荐(1) 编辑
摘要: Android开发应用除了程序应用,还有App Widget应用。好多人会开发程序应用而不会开发App Widget应用。本帖子就是帮助大家学习如何开发App Widget应用的。先简单说说App Widget的原理。App Widget是在桌面上的一块显示信息的东西,通过单击App Widget跳转到程序入口类。而系统自带的程序,典型的App Widget是music,这个Android内置的音乐播放小程序。这个是典型的App Widget+app应用。就是一个程序既可以通过App Widget启动,也可以通过App启动。App Widget就是一个AppWidgetProvider+一个U 阅读全文
posted @ 2011-03-02 10:11 Ruthless 阅读(8433) 评论(1) 推荐(5) 编辑
  2011年2月28日
摘要: 实时文件夹是一种用来显示由某个ContentProvider提供的数据信息的桌面组件。要创建一个实时文件夹,必须要有两方面的支持。一方面是,要定义一个用来创建实时文件夹的Activity。另一方面是,所指定数据信息URI的ContentProvider必须支持实时文件夹的查询。本节中就将要介绍如何为应用程序创建实时文件夹。 与在Launcher的桌面上添加一个快捷方式类似,用户在桌面上长按后选择实时文件夹就会弹出一个可用实时文件夹的列表对话框。若我们想把自己应用程序内的Activity也添加到这一列表中,同样只需要在该Activity注册时添加一个Action为android.intent.a 阅读全文
posted @ 2011-02-28 21:56 Ruthless 阅读(2266) 评论(0) 推荐(1) 编辑
摘要: 当我们在应用程序Launcher的桌面空白处长按触摸时,会出现一个对话框,提示选择要添加的桌面组件,如下图所示选择快捷方式后,会弹出一个对话框,显示出了可添加快捷方式的Activity所属的应用程序的图标和名称的列表。当我们想把添加快捷方式的Activity添加到这一列表时,只需要在这个Activity注册时添加一个Action为android.intent.action.CREATE_SHORTCUT的IntentFilter就可以了。ShortCutAction类package com.ljq.action;import android.app.Activity;import androi 阅读全文
posted @ 2011-02-28 20:53 Ruthless 阅读(3039) 评论(0) 推荐(1) 编辑
摘要: Android 快捷方式是桌面最基本的组件。它用于直接启动某一应用程序的某个组件。一般情况下,可以在Launcher的应用程序列表上,通过长按某一个应用程序的图标在左面上创建改该应用程序的快捷方式。另外,还可以通过两种方式在桌面上添加快捷方式:一:在应用程序中创建一个Intent,然后以Broadcast的形式通知Launcher创建一个快捷方式。二:为应用程序的组件注册某一个符合特定条件的IntentFilter,然后可以直接在Launcher的桌面添加启动该组件的快捷方式。下面模拟在应用程序中添加快捷方式main.xml布局文件<?xml version="1.0" 阅读全文
posted @ 2011-02-28 17:17 Ruthless 阅读(12074) 评论(0) 推荐(1) 编辑
  2011年2月26日
摘要: 一、开发手机闹钟主要用到了AlarmManager类,AlarmManager类提供了访问系统定时服务的途径,开发人员可以在程序中设置某个应用程序在未来的某个时刻被执行。当AlarmManager定时时间到了之后,当初注册的Intent对象将会被系统广播,进而启动目标程序。二、在程序运行时当需要使用AlarmManager类时,可以通过Context对象的getSystemService(Context.ALARM_SERVICE)方法来获得AlarmManager对象。以下程序中使用时间选择对话框设置闹钟的时间。main.xml布局文件<?xml version="1.0&q 阅读全文
posted @ 2011-02-26 23:45 Ruthless 阅读(24460) 评论(6) 推荐(2) 编辑
摘要: 原理概述: 手机电池电量的获取在应用程序的开发中也很常用,Android系统中手机电池电量发生变化的消息是通过Intent广播来实现的,常用的Intent的Action有Intent.ACTION_BATTERY_CHANGED(电池电量发生改变时)、Intent.ACTION_BATTERY_LOW(电池电量达到下限时)、和Intent.ACTION_BATTERY_OKAY(电池电量从低恢复到高时)。 当需要在程序中获取电池电量的信息时,需要为应用程序注册BroadcastReceiver组件,当特定的Action事件发生时,系统将会发出相应的广播,应用程序就可以通过BroadcastRe 阅读全文
posted @ 2011-02-26 21:55 Ruthless 阅读(8043) 评论(3) 推荐(2) 编辑
摘要: 目录结构main.xml布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> 阅读全文
posted @ 2011-02-26 21:20 Ruthless 阅读(8914) 评论(2) 推荐(2) 编辑
摘要: TelephonyManager类主要提供了一系列用于访问与手机通讯相关的状态和信息的get方法。其中包括手机SIM的状态和信息、电信网络的状态及手机用户的信息。在应用程序中可以使用这些get方法获取相关数据。 TelephonyManager类的对象可以通过Context.getSystemService(Context.TELEPHONY_SERVICE)方法来获得,需要注意的是有些通讯信息的获取对应用程序的权限有一定的限制,在开发的时候需要为其添加相应的权限。以下列出TelephonyManager类所有方法及说明:package com.ljq.activity;import jav. 阅读全文
posted @ 2011-02-26 12:47 Ruthless 阅读(47611) 评论(2) 推荐(5) 编辑
  2011年2月25日
摘要: main.xml布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> &l 阅读全文
posted @ 2011-02-25 21:26 Ruthless 阅读(17151) 评论(0) 推荐(2) 编辑
摘要: main.xml布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> &l 阅读全文
posted @ 2011-02-25 20:33 Ruthless 阅读(17234) 评论(3) 推荐(1) 编辑
摘要: main.xml布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> &l 阅读全文
posted @ 2011-02-25 12:01 Ruthless 阅读(1586) 评论(1) 推荐(1) 编辑
摘要: 模拟当点击按钮时,使手机朝向发生改变。main.xml布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_ 阅读全文
posted @ 2011-02-25 10:36 Ruthless 阅读(17955) 评论(0) 推荐(1) 编辑
  2011年2月24日
摘要: 以下模拟下拉列表的用法布局文件<?xml version="1.0" encoding="utf-8"?><LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" xmlns:android="http://sc 阅读全文
posted @ 2011-02-24 16:58 Ruthless 阅读(13952) 评论(0) 推荐(0) 编辑
摘要: 以下通过TabHost实现android选项卡。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"> <LinearLayout an 阅读全文
posted @ 2011-02-24 16:20 Ruthless 阅读(7436) 评论(0) 推荐(1) 编辑