代码改变世界

善用系统自带图标

2010-12-03 14:28 by RayLee, 610 阅读, 0 推荐, 收藏, 编辑
摘要:如果你仅仅是一个programmer,在开发应用程序时是不是常常为寻找合适的图标而烦恼?其实,Android平台提供了一些常用的图标。熟练使用这些图标会使你的应用看起来更专业。 android.R.drawable类定义了一些常用的图标,它们按照类别来分类。 Icons for menu 以ic_menu_开头的图标都是供菜单项使用的。 一个应用程序最常见的三个菜单项可能是“退出”,“关于”,“设置”。 它们与图标的对应关系依次为: “退出”- ic_menu_close_clear_cancel “关于”- ic_menu_info_details “设置”- ic_m 阅读全文

自定义标题栏

2010-12-03 10:25 by RayLee, 609 阅读, 0 推荐, 收藏, 编辑
摘要:应用程序默认的标题栏仅仅是文字显示,过于单调。Android允许自定义标题栏以显示更丰富的内容。下面是实现的步骤: 自定义标题栏布局 创建window_title.xml 值得注意的是,对TextView需要应用style="?android:attr/windowTitleStyle",否则就是普通的字体显示,而不是放大的高亮的标题栏字体显示。应用自定义布局创建好自定义布局后,在Activity初始化时应用该布局来看看最终的效果图吧 阅读全文

善用Android预定义样式

2010-12-02 15:41 by RayLee, 11697 阅读, 1 推荐, 收藏, 编辑
摘要:字体大小 对于能够显示文字的控件(如TextView EditText RadioButton Button CheckBox Chronometer等等),你有时需要控制字体的大小。Android平台定义了三种字体大小。 "?android:attr/textAppearanceLarge" "?android:attr/textAppearanceMedium" "?android:attr/textAppearanceSmall" 使用方法为: android:textAppearance="?android:attr/textAppearanceLarge" android 阅读全文

Understanding User Interface in Android

2010-12-01 16:22 by RayLee, 211 阅读, 0 推荐, 收藏, 编辑
摘要:转载一系列文章 Understanding User Interface in Android - Part 1: Layouts http://mobiforge.com/designing/story/understanding-user-interface-android-part-1-layouts Understanding User Interface in Android - Part 2: Views http://mobiforge.com/designing/story/understanding-user-interface-android-part-2-view 阅读全文

Android source开发环境搭建

2010-11-23 15:07 by RayLee, 1276 阅读, 0 推荐, 收藏, 编辑
摘要:众所周知,Android是开源的。这样就可以下载Android的全部代码,进行编译生成二进制镜象文件。 开发平台 Ubuntu. 工具安装 $ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf     libsdl-dev libesd0-dev libwxgtk2.6-dev build-essenti... 阅读全文

Android video recording demo

2010-11-18 13:24 by RayLee, 1186 阅读, 0 推荐, 收藏, 编辑
摘要:UI 提供三个功能按钮:‘Start video recording’,‘Stop video recording’和‘Play video’。 Android平台针对视频设计了一个更抽象的控件VideoView。下面是UI的XML 文件。 功能实现附一张截图: 阅读全文

java.lang.OutOfMemoryError: bitmap size exceeds VM budget解决方法

2010-11-09 17:13 by RayLee, 6762 阅读, 1 推荐, 收藏, 编辑
摘要:用BitmapFactory解码一张图片时,有时会遇到该错误。这往往是由于图片过大造成的。要想正常使用,则需要分配更少的内存空间来存储。BitmapFactory.Options.inSampleSize设置恰当的inSampleSize可以使BitmapFactory分配更少的空间以消除该错误。inSampleSize的具体含义请参考SDK文档。例如:如何设置恰当的inSampleSize设置恰当的inSampleSize是解决该问题的关键之一。BitmapFactory.Options提供了另一个成员inJustDecodeBounds。设置inJustDecodeBounds为true后 阅读全文

关键字volatile的作用

2010-10-22 12:00 by RayLee, 439 阅读, 0 推荐, 收藏, 编辑
摘要:很多人可能对关键字volatile的作用不太清楚。首先,该关键字是用在多线程环境中的,今天从别人的文章中找到了一个例子说明,以帮助理解。 The volatile keyword was introduced to the language as a way around optimizing compilers. Take the following code for example: An optimizing compiler might decide that the body of the if statement would never execute, and not eve 阅读全文

JNI系列(4):如何访问自定义类对象

2010-10-21 13:51 by RayLee, 3731 阅读, 0 推荐, 收藏, 编辑
摘要:JNI规范中仅仅给出了String,Array两种引用类型的访问,那么如果使用了自定义的类,在JNI中该如何访问?如以下代码所示,用户自定义了Student类,创建了实例student,并希望在JNI函数中修改实例student的成员age。 对应的JNI函数:其实思路是一样的,先找到Student类,然后找到’age’的fieldID。 阅读全文

JN系列(3):如何得到JavaVM,JNIEnv接口

2010-10-21 11:49 by RayLee, 11610 阅读, 0 推荐, 收藏, 编辑
摘要:在系列(1)中讲到,Java与native code的操作有两种方式:(1)在Java中加载动态链接库(2)使用JNI Invocation inteface,在native code中创建JVM JavaVM接口 第一种方式,在加载动态链接库的时候,JVM会调用JNI_OnLoad(JavaVM* jvm, void* reserved)(如果定义了该函数)。第一个参数会传入JavaVM指针。 第二种方式,在native code中调用JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args)可以得到JavaVM指针。 两种情况下,都可以用全局变量, 阅读全文