第一:FrameLayout的妙用,框架布局是最简单和最高效的布局类型之一。框架布局的子控件被相对于布局的左上角来绘制。如果框架布局中存在多个子视图,它们将按顺序绘制,最后一个子控件绘制在最上面。
示例:。
第二:以前做J2ME平台,为了实现跑马灯效果,实现方式是在UI线程(绘图线程)不停的刷新,通过改变坐标来达到动画效果。那时候看到Android上各种炫目的动画,简直吓尿了,后来做了Android平台才知道,尿尿更健康。在Android平台,动画效果封装的非常好。简单的动画模型有两种:tweened (透明/伸缩/移动/旋转)和frame ,下面的下载链接有这两种动画的demo:http://download.csdn.net/detail/coding_or_coded/4367757
第三:Android平台的Gallery可以实现很棒的图片拖动效果,demo下载地址:http://download.csdn.net/detail/coding_or_coded/4368287
第四:实现了一个非常棒的SharedPreferences封装类
package com.imo.util;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.imo.global.IMOApp;
/**
* SharedPreference封装
*/
public class PreferenceManager {
/**
* 在指定的文件中保存数据
*
* @param fileName
* 文件名称
* @param objs
* 数组{key,value}
*/
public static void save(String fileName, Object[] objs) {
try {
SharedPreferences sp = IMOApp.getApp().getSharedPreferences(fileName,Context.MODE_APPEND);//IMOApp.getApp()代表Application
Editor editor = sp.edit();
if (objs[1] instanceof String) {
editor.putString(objs[0].toString(), objs[1].toString());
} else if (objs[1] instanceof Integer) {
editor.putInt(objs[0].toString(),Integer.parseInt(objs[1].toString()));
} else if (objs[1] instanceof Long) {
editor.putLong(objs[0].toString(),Long.parseLong((objs[1].toString())));
} else if (objs[1] instanceof Float) {
editor.putFloat(objs[0].toString(),Float.parseFloat((objs[1].toString())));
} else if (objs[1] instanceof Boolean) {
editor.putBoolean(objs[0].toString(),Boolean.parseBoolean((objs[1].toString())));
}
editor.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 在指定的文件中读取数据
*
* @param fileName
* 文件名称
* @param objs
* 数组{key,defaultValue}
*/
public static Object get(String fileName, Object[] objs) {
try {
SharedPreferences sp = IMOApp.getApp().getSharedPreferences(fileName,Context.MODE_APPEND);
if (objs[1] instanceof String) {
return sp.getString(objs[0].toString(), objs[1].toString());
} else if (objs[1] instanceof Integer) {
return sp.getInt(objs[0].toString(),Integer.parseInt(objs[1].toString()));
} else if (objs[1] instanceof Long) {
return sp.getLong(objs[0].toString(),Long.parseLong((objs[1].toString())));
} else if (objs[1] instanceof Float) {
return sp.getFloat(objs[0].toString(),Float.parseFloat((objs[1].toString())));
} else if (objs[1] instanceof Boolean) {
return sp.getBoolean(objs[0].toString(),Boolean.parseBoolean((objs[1].toString())));
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}