欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android中引用其他程序的文本資源超簡(jiǎn)單方法

 更新時(shí)間:2015年01月19日 08:52:50   投稿:junjie  
這篇文章主要介紹了Android中引用其他程序的文本資源超簡(jiǎn)單方法,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下

在Android中引用其他程序的文本資源并不是很常見,但是有時(shí)候還是很是有需要的,通常引用的多半是系統(tǒng)的程序的文本資源.

下面以一個(gè)超簡(jiǎn)單的例子,來(lái)展示以下如何實(shí)現(xiàn).

復(fù)制代碼 代碼如下:

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();
    }

}

相關(guān)文章

最新評(píng)論