Tip: In Eclipse, press Ctrl + Shift + O to import missing classes (Cmd + Shift + O on Mac);
Tip:使用view的onClick属性
android:onClick="clickMethod"
但是clickMethod方法签名必须是 public void clickMethod(View v);
Tip:使用最新adt bundle中的"File"->"New"->"Others"->"Android"->"Ändroid Activity"来创建activity,adt工具会自动创建该activity的布局、字符串资源并修改AndroidManifest文件,以避免粗心漏写某些内容;
Tip:经常去这里看看当前android手机系统分布,这个是google官方根据访问google play的设备信息做的统计,会定期更新。http://developer.android.com/about/dashboards/index.html
Tip:Activity中使用fragment的方式有两种,一种是在activity的布局xml中声明fragment;还有一种是在运行时动态添加或者移除fragment。对于第一种使用方式,一旦创建,在运行期间就无法动态添加或者移除fragment。
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
int memClass = activityManager.getMemoryClass();
final int cacheSize = 1024 * 1024 * memClass / 8;