Hay*_*ley 5 android android-framework android-resources
所以我注意到似乎有两种方法可以获得相同的数据,而且我不确定是否有指导何时应该使用(除了绕过getResources可以节省内存,如果你不实际上想要多次使用该对象).但除此之外,我想知道是否有使用指南或理由
Context.getText(id)vs Context.getResources.getText(id)
有人可以帮忙吗?
没有区别.getText(id)的来源是:
/**
* Return a localized, styled CharSequence from the application's package's
* default string table.
*
* @param resId Resource id for the CharSequence text
*/
public final CharSequence getText(int resId) {
return getResources().getText(resId);
}
Run Code Online (Sandbox Code Playgroud)
你可以在netmite上的Context.java上看到它,它有一个Android源版本.