做完第一個android項目,在android知識點上增加的經驗值

來源:互聯網
上載者:User

第一: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()代表ApplicationEditor 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;}}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.