在android中引用其他程序的文本资源并不是很常见,但是有时候还是很是有需要的,通常引用的多半是系统的程序的文本资源.
上述就是android开发分享Android中引用其他程序的文本资源超简单方法的全部内容,如果对大家有所用处且需要了解更多关于Android学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
下面以一个超简单的例子,来展示以下如何实现.
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();
}
}
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/addevelopment/940689.html