編輯:Android開發教程
Roboguice 對訪問res 目錄下各種資源drawable, arrary, string 等也提供 了注入支持。可以通過@InjectResource 很方便的應用所需資源。
本例修 改Android ApiDemos示例解析(48):Content->Resources->Resources 使 用Inject Resource方法來訪問資源。
public class
InjectResourceDemo extends RoboActivity {
@InjectView (R.id.styled_text) TextView styled_text;
@InjectView (R.id.plain_text) TextView plain_text;
@InjectView (R.id.res1) TextView res1;
@Inject Resources res;
@InjectResource(R.string.styled_text) String str;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.injectresource);
//Use res to get the string resources
CharSequence cs=res.getText(R.string.styled_text);
// Note the use of
// CharSequence instead of String
// so we don't lose the style info.
styled_text.setText(cs);
// Use the same resource, but convert it to
// a string, which causes it
// to lose the style information.
plain_text.setText(str);
res1.setText(cs);
}
}

本例下載: http://www.imobilebbs.com/download/android/roboguice/InjectResourceDemo .zip
查看全套文章:http://www.bianceng.cn/OS/extra/201301/34950.htm
Android ApiDemos示例解析 (27)
App->Notification->Notifying Service Controller這個例子介紹了如何在Service中使用Notification
Android簡明開發教程十三:Option Menu畫筆示例
引路蜂二維圖形畫筆(Pen)示例含有四個示例,Lines ,Dashes ,LineJoin 和LineCap。打算采用Option Menu(主菜單) 的方式來選擇不同
Android開發入門(十九)數據庫 19.2 使用數據庫
DBAdapter已經創建好了,現在我們可以去使用數據庫了。下面的章節,將介紹常規的CRUD(增加,讀取, 更新,刪除)。往表中添加聯系人。1. 使用之前的項目,在Dat
android的開發調試工具
android開發中,解決bug有很多優秀的工具,現列舉如下:一.charles:網絡抓包神器專解各種網絡解析錯誤等網絡異常重定向host的方法:1. charles的m