顯示具有 androidResource 標籤的文章。 顯示所有文章
顯示具有 androidResource 標籤的文章。 顯示所有文章

2012年2月20日 星期一

[AndroidResources] String with HTML tag


    (%1$s)<a href=\"http:\">
    


若是直接使用在 layout 中,則可直接使用 info2

但若如 info 中有變數必須填入則必需 escape

使用 StringFormat 再使用 Html.fromHtml

才 set 給 view


2011年12月27日 星期二

[Android] Call getResource() after onCreate()

Error Message

12-13 14:49:27.316: E/AndroidRuntime(881): Caused by: java.lang.NullPointerException
12-13 14:49:27.316: E/AndroidRuntime(881): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)

Occurred when
call getResources out of onCreate


Solution

Must using getResource() after onCreate()

...but why?

2011年9月24日 星期六

[Android] app name setting and showing location

* When new an android project, you will see these information needed to fill:
  • Project name
    • 顯示在 eclipse 中的專案名稱。
    • export 時的預設名稱。
  • Application name
    • strings.xml 中預設產生的 app_name 的名稱。
    • activity 和 應用程式的預設名稱。
  • Package name
    • 預設產生的專案hierarchy。
    • AndroidManifest 中預設的 package name identifier.
    • BUT!
      • package hierarchy does not have directly relationship with package identifier. (?)
      • package identifier is relative to R.

* 在安裝 app 時,在 android installer 中的顯示名稱
  • 預設是使用<application>中的 label
  • 若沒有指定時,則是用 package name



* debug key apk cannot used to publish your app.

2011年8月13日 星期六

[Resources] style setting

不可直接在 style 中使用 @+id/id_name (新增新的id) 


不會出錯


但會造成 aapt error 無法產生 gen



2011年7月23日 星期六

[Resource] Draw 9-patch

* android SDK 中所提供的工具,位於 (SDK path)\tools\draw9patch.bat

* 讓圖片可以放大(變長或變寬)並且不會失真。

* 工具中:
圖片旁邊會有 1 px 的空白,在想放大的邊點選這 1 px 的空白。

Zoom:只是單純讓你放大圖片,比較好操作,不會對最終檔案有影響!
Patch scale:只是讓你看圖片最終變長、變寬以後的樣子。在你儲存前都可以修改!

做法可參考Draw 9-patch

* 調整好的檔案 檔名應儲存為 fileName.9.png

* 在 SDK 2.3 版使用此工具時會出現 NoClassDefFoundError,請見[Android]draw9patch 的 NoClassDefFoundError 解決方法


* Reference
- Draw 9-patch
- NinePatch
- Draw 9-patch **
- [Android]draw9patch 的 NoClassDefFoundError 解決方法
- Draw 9-patch Tutorial **
- android 工具 Draw 9-patch 详解 **
- Android学习系列(4)--App自适应draw9patch不失真背景 ***
- android draw 9-path使用总结
- android 9patch ****