Android中引用其他程序的文本資源超簡單方法
在Android中引用其他程序的文本資源并不是很常見,但是有時候還是很是有需要的,通常引用的多半是系統(tǒng)的程序的文本資源.
下面以一個超簡單的例子,來展示以下如何實現(xiàn).
public void testUseAndroidString() {
Context context = getContext();
Resources res = null;
try {
//I want to use the clear_activities string in Package com.android.settings
res = context.getPackageManager().getResourcesForApplication("com.android.settings");
int resourceId = res.getIdentifier("com.android.settings:string/clear_activities", null, null);
if(0 != resourceId) {
CharSequence s = context.getPackageManager().getText("com.android.settings", resourceId, null);
Log.i(VIEW_LOG_TAG, "resource=" + s);
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
- android實現(xiàn)文本復制到剪切板功能(ClipboardManager)
- android 手機SD卡讀寫操作(以txt文本為例)實現(xiàn)步驟
- Android的文本和輸入之創(chuàng)建輸入法教程
- Android編程之SMS讀取短信并保存到SQLite的方法
- Android操作存放在assets文件夾下SQLite數(shù)據(jù)庫的方法
- Android SQLite數(shù)據(jù)庫操作代碼類分享
- android創(chuàng)建數(shù)據(jù)庫(SQLite)保存圖片示例
- Android使用SQLite數(shù)據(jù)庫的簡單實例
- android中sqlite的按條件查找的小例子
- 深入Android SQLite 事務處理詳解
- android編程實現(xiàn)添加文本內容到sqlite表中的方法
相關文章
Android程序開發(fā)之ListView 與PopupWindow實現(xiàn)從左向右滑動刪除功能
這篇文章主要介紹了Android程序開發(fā)之ListView 與PopupWindow實現(xiàn)滑動刪除功能的相關資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-07-07
Android使用OKHttp包處理HTTP相關操作的基本用法講解
這篇文章主要介紹了Android使用OKHttp包處理HTTP相關操作的基本用法講解,包括操作如何利用OKHttp操作HTTP請求與處理緩存等內容,需要的朋友可以參考下2016-07-07
Android之Intent附加數(shù)據(jù)的兩種實現(xiàn)方法
這篇文章主要介紹了Android之Intent附加數(shù)據(jù)的兩種實現(xiàn)方法,以實例形式較為詳細的分析了添加數(shù)據(jù)到Intent的相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09

