本文整理了Java中android.content.res.Resources.getText
方法的一些代码示例,展示了Resources.getText
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resources.getText
方法的具体详情如下:
包路径:android.content.res.Resources
类名称:Resources
方法名:getText
暂无
代码示例来源:origin: facebook/litho
public CharSequence getText(@StringRes int resId) {
return mContext.getResources().getText(resId);
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
public ActionItem(Context context, int titleId, int drawableId) {
this.mTitle = context.getResources().getText(titleId);
this.mDrawable = context.getResources().getDrawable(drawableId);
}
代码示例来源:origin: crazycodeboy/TakePhoto
/**
* 检查文件类型是否是图片
*
* @param minType
* @return
*/
public static boolean checkMimeType(Context context, String minType) {
boolean isPicture =
TextUtils.isEmpty(minType) ? false : ".jpg|.gif|.png|.bmp|.jpeg|.webp|".contains(minType.toLowerCase()) ? true : false;
if (!isPicture) {
Toast.makeText(context, context.getResources().getText(org.devio.takephoto.R.string.tip_type_not_image), Toast.LENGTH_SHORT).show();
}
return isPicture;
}
代码示例来源:origin: Naoki2015/CircleDemo
public ActionItem(Context context, int titleId, int drawableId) {
this.mTitle = context.getResources().getText(titleId);
this.mDrawable = context.getResources().getDrawable(drawableId);
}
代码示例来源:origin: smuyyh/BookReader
public static Toast getSingleToast(int resId, int duration) { // 连续调用不会连续弹出,只是替换文本
return getSingleToast(context.getResources().getText(resId).toString(), duration);
}
代码示例来源:origin: smuyyh/BookReader
public static Toast getToast(int resId, int duration) { // 连续调用会连续弹出
return getToast(context.getResources().getText(resId).toString(), duration);
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 自定义显示Toast时间
*
* @param context
* @param strResId
* @param duration
*/
public static void show(Context context, int strResId, int duration) {
initToast(context.getResources().getText(strResId), duration).show();
}
代码示例来源:origin: novoda/android-demos
@Override
public Tab setContentDescription(int resId) {
return setContentDescription(mContext.getResources().getText(resId));
}
代码示例来源:origin: north2016/T-MVP
public static void show(int resId, int duration) {
show(context.getResources().getText(resId), duration);
}
代码示例来源:origin: ZieIony/Carbon
@CheckResult
@NonNull
default Consumer<? super Integer> errorRes() {
return (Consumer<Integer>) textRes -> ((android.widget.TextView) this).setError(((android.widget.TextView) this).getContext().getResources().getText(textRes));
}
代码示例来源:origin: Flipboard/bottomsheet
/**
* Sets the title text of the sheet
*
* @param resId String resource ID for the text
*/
public void setTitle(@StringRes int resId) {
setTitle(getResources().getText(resId));
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 短时间显示Toast
*
* @param strResId
*/
public static void showShort(int strResId) {
// Toast.makeText(context, strResId, Toast.LENGTH_SHORT).show();
initToast(BaseApplication.getAppContext().getResources().getText(strResId), Toast.LENGTH_SHORT).show();
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 长时间显示Toast
*
* @param strResId
*/
public static void showLong(int strResId) {
initToast(BaseApplication.getAppContext().getResources().getText(strResId), Toast.LENGTH_LONG).show();
}
代码示例来源:origin: crazycodeboy/TakePhoto
/**
* 拍照前检查是否有相机
**/
public static void captureBySafely(TContextWrap contextWrap, TIntentWap intentWap) throws TException {
List result = contextWrap.getActivity().getPackageManager().queryIntentActivities(intentWap.getIntent(), PackageManager.MATCH_ALL);
if (result.isEmpty()) {
Toast.makeText(contextWrap.getActivity(), contextWrap.getActivity().getResources().getText(R.string.tip_no_camera),
Toast.LENGTH_SHORT).show();
throw new TException(TExceptionType.TYPE_NO_CAMERA);
} else {
startActivityForResult(contextWrap, intentWap);
}
}
代码示例来源:origin: android-hacker/VirtualXposed
@SuppressLint("MissingSuperCall")
@Override
protected void onCreate(Bundle savedInstanceState) {
final int titleResource;
final Intent intent = makeMyIntent();
final Set<String> categories = intent.getCategories();
if (Intent.ACTION_MAIN.equals(intent.getAction())
&& categories != null
&& categories.size() == 1
&& categories.contains(Intent.CATEGORY_HOME)) {
titleResource = R.string.choose;
} else {
titleResource = R.string.choose;
}
onCreate(savedInstanceState, intent, getResources().getText(titleResource),
null, null, true, VUserHandle.getCallingUserId());
}
代码示例来源:origin: android-hacker/VirtualXposed
private void buildTypeToAuthDescriptionMap() {
for(AuthenticatorDescription desc : VAccountManager.get().getAuthenticatorTypes()) {
String name = null;
Drawable icon = null;
try {
Resources res = VirtualCore.get().getResources(desc.packageName);
icon = res.getDrawable(desc.iconId);
final CharSequence sequence = res.getText(desc.labelId);
name = sequence.toString();
name = sequence.toString();
} catch (Resources.NotFoundException e) {
// Nothing we can do much here, just log
VLog.w(TAG, "No icon resource for account type " + desc.type);
}
AuthInfo authInfo = new AuthInfo(desc, name, icon);
mTypeToAuthenticatorInfo.put(desc.type, authInfo);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getText_plainString() throws Exception {
assertThat(resources.getText(R.string.hello, "value").toString()).isEqualTo("Hello");
assertThat(resources.getText(R.string.hello)).isInstanceOf(String.class);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getText_withHtml() throws Exception {
assertThat(resources.getText(R.string.some_html, "value").toString()).isEqualTo("Hello, world");
// TODO: Raw resources have lost the tags early, but the following call should return a
// SpannedString
// assertThat(resources.getText(R.string.some_html)).isInstanceOf(SpannedString.class);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getText_withLayoutId() throws Exception {
// This isn't _really_ supported by the platform (gives a lint warning that getText() expects a String resource type
// but the actual platform behaviour is to return a string that equals "res/layout/layout_file.xml" so the current
// Robolectric behaviour deviates from the platform as we append the full file path from the current working directory.
assertThat(resources.getText(R.layout.different_screen_sizes, "value").toString())
.containsMatch("layout" + File.separator + "different_screen_sizes.xml$");
}
代码示例来源:origin: crazycodeboy/TakePhoto
/**
* -----crop------
**/
@Override
public void onCrop(Uri imageUri, Uri outPutUri, CropOptions options) throws TException {
if (PermissionManager.TPermissionType.WAIT.equals(permissionType)) {
return;
}
this.outPutUri = outPutUri;
if (!TImageFiles.checkMimeType(contextWrap.getActivity(), TImageFiles.getMimeType(contextWrap.getActivity(), imageUri))) {
Toast.makeText(contextWrap.getActivity(), contextWrap.getActivity().getResources().getText(org.devio.takephoto.R.string.tip_type_not_image),
Toast.LENGTH_SHORT).show();
throw new TException(TExceptionType.TYPE_NOT_IMAGE);
}
cropWithNonException(imageUri, outPutUri, options);
}
内容来源于网络,如有侵权,请联系作者删除!