android.content.Context.getText()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中android.content.Context.getText()方法的一些代码示例,展示了Context.getText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getText()方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:getText

Context.getText介绍

暂无

代码示例

代码示例来源:origin: ankidroid/Anki-Android

private String gtxt(int id) {
  return mContext.getText(id).toString();
}

代码示例来源:origin: stackoverflow.com

public static class MyOtherAlertDialog {

 public static AlertDialog create(Context context) {
 final TextView message = new TextView(context);
 // i.e.: R.string.dialog_message =>
      // "Test this dialog following the link to dtmilano.blogspot.com"
 final SpannableString s = 
        new SpannableString(context.getText(R.string.dialog_message));
 Linkify.addLinks(s, Linkify.WEB_URLS);
 message.setText(s);
 message.setMovementMethod(LinkMovementMethod.getInstance());

 return new AlertDialog.Builder(context)
  .setTitle(R.string.dialog_title)
  .setCancelable(true)
  .setIcon(android.R.drawable.ic_dialog_info)
  .setPositiveButton(R.string.dialog_action_dismiss, null)
  .setView(message)
  .create();
 }
}

代码示例来源:origin: yanzhenjie/NoHttp

public final CharSequence getText(@StringRes int id) {
  return getContext().getText(id);
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

img_tip_logo.setVisibility(View.VISIBLE);
  progress.setVisibility(View.GONE);
  tv_tips.setText(getContext().getText(R.string.empty).toString());
  img_tip_logo.setImageResource(R.drawable.no_content_tip);
  break;
  progress.setVisibility(View.GONE);
  if (TextUtils.isEmpty(errorMsg)){
    tv_tips.setText(getContext().getText(R.string.net_error).toString());
  }else {
    tv_tips.setText(errorMsg);
  progress.setVisibility(View.GONE);
  if (TextUtils.isEmpty(errorMsg)){
    tv_tips.setText(getContext().getText(R.string.net_error).toString());
  }else {
    tv_tips.setText(errorMsg);
  img_tip_logo.setVisibility(View.GONE);
  progress.setVisibility(View.VISIBLE);
  tv_tips.setText(getContext().getText(R.string.loading).toString());
  break;
case finish:

代码示例来源:origin: airbnb/epoxy

@Test
public void stringResIsSet() {
 int stringWithNoArgs = R.string.string_with_no_args;
 ViewWithAnnotationsForIntegrationTestModel_ model =
   new ViewWithAnnotationsForIntegrationTestModel_()
     .requiredText(stringWithNoArgs);
 ViewWithAnnotationsForIntegrationTest view = bind(model);
 assertEquals(view.getContext().getText(stringWithNoArgs), view.requiredText);
}

代码示例来源:origin: dkim0419/SoundRecorder

public void shareFileDialog(int position) {
  Intent shareIntent = new Intent();
  shareIntent.setAction(Intent.ACTION_SEND);
  shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(getItem(position).getFilePath())));
  shareIntent.setType("audio/mp4");
  mContext.startActivity(Intent.createChooser(shareIntent, mContext.getText(R.string.send_to)));
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

/**
 * Sets the tab's title.
 *
 * @param context
 *         The context, which should be used, as an instance of the class {@link Context}. The
 *         context may not be null
 * @param resourceId
 *         The resource id of the title, which should be set, as an {@link Integer} value. The
 *         resource id must correspond to a valid string resource
 */
public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) {
  setTitle(context.getText(resourceId));
}

代码示例来源:origin: syncthing/syncthing-android

public void showStopSyncthingWarningNotification() {
    final String msg = mContext.getString(R.string.appconfig_receiver_background_enabled);
    NotificationCompat.Builder nb = getNotificationBuilder(mInfoChannel)
        .setContentText(msg)
        .setTicker(msg)
        .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
        .setContentTitle(mContext.getText(mContext.getApplicationInfo().labelRes))
        .setSmallIcon(R.drawable.ic_stat_notify)
        .setAutoCancel(true)
        .setContentIntent(PendingIntent.getActivity(mContext, 0,
            new Intent(mContext, MainActivity.class),
            PendingIntent.FLAG_UPDATE_CURRENT));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      nb.setCategory(Notification.CATEGORY_ERROR);
    }
    mNotificationManager.notify(ID_STOP_BACKGROUND_WARNING, nb.build());
  }
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

@Override
public void setToolbarTitle(@StringRes final int resourceId) {
  setToolbarTitle(getContext().getText(resourceId));
}

代码示例来源:origin: ukanth/afwall

private void deviceCheck() {
  if (Build.VERSION.SDK_INT >= 21) {
    if ((G.isDoKey(context) || isDonate())) {
      KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
      if (keyguardManager.isKeyguardSecure()) {
        Intent createConfirmDeviceCredentialIntent = keyguardManager.createConfirmDeviceCredentialIntent(null, null);
        if (createConfirmDeviceCredentialIntent != null) {
          try {
            activity.startActivityForResult(createConfirmDeviceCredentialIntent, LOCK_VERIFICATION);
          } catch (ActivityNotFoundException e) {
          }
        }
      } else {
        Toast.makeText(activity, context.getText(R.string.android_version), Toast.LENGTH_SHORT).show();
      }
    } else {
      Api.donateDialog(activity, true);
    }
  }
}

代码示例来源:origin: ukanth/afwall

public static void donateDialog(final Context ctx, boolean showToast) {
  if (showToast) {
    Toast.makeText(ctx, ctx.getText(R.string.donate_only), Toast.LENGTH_LONG).show();
  } else {
    try {
          .show();
    } catch (Exception e) {
      Toast.makeText(ctx, ctx.getText(R.string.donate_only), Toast.LENGTH_LONG).show();

代码示例来源:origin: stackoverflow.com

public class NonActivity {

  public static void doStuff(Context context) {
    String TTT = context.getText(R.string.TTT);
    ...
  }
}

代码示例来源:origin: stackoverflow.com

public static CharSequence getText(Context context, int id, Object... args) {
  for(int i = 0; i < args.length; ++i)
    args[i] = args[i] instanceof String? TextUtils.htmlEncode((String)args[i]) : args[i];
  return Html.fromHtml(String.format(Html.toHtml(new SpannedString(context.getText(id))), args));
}

代码示例来源:origin: PrivacyApps/document-viewer

@Override
public int notify(final int titleId, final int messageId) {
  final CharSequence title = BaseDroidApp.context.getText(titleId);
  final CharSequence message = BaseDroidApp.context.getText(messageId);
  return notify(title, message, null);
}

代码示例来源:origin: PrivacyApps/document-viewer

@Override
public int notify(final int titleId, final CharSequence message, final Intent intent) {
  final CharSequence title = BaseDroidApp.context.getText(titleId);
  return notify(title, message, intent);
}

代码示例来源:origin: smuyyh/SprintNBA

public void onRefreshComplete() {
  mState = DONE;
  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd  HH:mm");
  String date = format.format(new Date());
  mHtvTime.setText(getContext().getText(R.string.pull_to_refresh_date) + date);
  changeHeaderViewByState();
}

代码示例来源:origin: fookwood/Launcher3

public OverviewScreenAccessibilityDelegate(Workspace workspace) {
  mWorkspace = workspace;
  Context context = mWorkspace.getContext();
  boolean isRtl = Utilities.isRtl(context.getResources());
  mActions.put(MOVE_BACKWARD, new AccessibilityAction(MOVE_BACKWARD,
      context.getText(isRtl ? R.string.action_move_screen_right :
        R.string.action_move_screen_left)));
  mActions.put(MOVE_FORWARD, new AccessibilityAction(MOVE_FORWARD,
      context.getText(isRtl ? R.string.action_move_screen_left :
        R.string.action_move_screen_right)));
}

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

/**
 * Sets the prompt to display when the dialog is shown.
 * @param promptId the resource ID of the prompt to display when the dialog is shown
 */
public void setPromptId(int promptId) {
  setPrompt(getContext().getText(promptId));
}

代码示例来源:origin: listenzz/AndroidNavigation

public void setTitle(@StringRes int resId) {
  if (getContext() != null) {
    setTitle(getContext().getText(resId));
  }
}

代码示例来源:origin: fookwood/Launcher3

private void movePage(int finalIndex, View view) {
  mWorkspace.onStartReordering();
  mWorkspace.removeView(view);
  mWorkspace.addView(view, finalIndex);
  mWorkspace.onEndReordering();
  mWorkspace.announceForAccessibility(mWorkspace.getContext().getText(R.string.screen_moved));
  mWorkspace.updateAccessibilityFlags();
  view.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
}

相关文章

Context类方法