Example usage for android.content Context getString

List of usage examples for android.content Context getString

Introduction

In this page you can find the example usage for android.content Context getString.

Prototype

@NonNull
public final String getString(@StringRes int resId) 

Source Link

Document

Returns a localized string from the application's package's default string table.

Usage

From source file:Main.java

/**
 * /*  ww  w .j a  v a  2 s.  co  m*/
 * @param context
 * @param resId
 * @param gravity
 * @param xOffset
 * @param yOffset
 */
public static void showShort(Context context, int resId, int gravity, int xOffset, int yOffset) {
    showShort(context, context.getString(resId), gravity, xOffset, yOffset);
}

From source file:Main.java

/**
 * Show a yes/no dialog, providing the yes listener function
 *///from   w  w  w .  j a v  a  2s  .  co m
public static void showYesNoDialog(Context context, int titleRes, int msgRes,
        DialogInterface.OnClickListener posListener) {
    new AlertDialog.Builder(context).setTitle(context.getString(titleRes)).setMessage(context.getString(msgRes))
            .setNegativeButton(android.R.string.no, (dialogInterface, i) -> dialogInterface.cancel())
            .setPositiveButton(android.R.string.yes, posListener).show();
}

From source file:Main.java

/**
 * @param message/*from ww  w. jav a2  s  .c o m*/
 */
public static void showToast(int message, Toast mToast, Context context) {
    if (mToast == null) {
        mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
    }
    mToast.setText(context.getString(message));
    mToast.show();
}

From source file:Main.java

public static void showInfoDialog(Context ctx, String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    builder.setMessage(msg);//from ww w.  j  a  v  a2s .co m
    builder.setPositiveButton(ctx.getString(android.R.string.ok), new OnClickListener() {
        public void onClick(DialogInterface dialog, int arg1) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

/**
 * @return string of fallBackRessource param if not existing
 *//*from ww  w.  j a va2  s .com*/
public static String getResourceString(Context context, String name, int fallBackRessource) {
    String string = getResourceString(context, name);
    return string == null ? context.getString(fallBackRessource) : string;
}

From source file:com.unitedcoders.android.gpodroid.tools.Tools.java

public static String makeTimeString(Context context, long secs) {
    String durationformat = context
            .getString(secs < 3600 ? R.string.durationformatshort : R.string.durationformatlong);

    /* Provide multiple arguments so the format can be changed easily
    * by modifying the xml./*  w w w .java2s.c om*/
    */
    sFormatBuilder.setLength(0);

    final Object[] timeArgs = sTimeArgs;
    timeArgs[0] = secs / 3600;
    timeArgs[1] = secs / 60;
    timeArgs[2] = (secs / 60) % 60;
    timeArgs[3] = secs;
    timeArgs[4] = secs % 60;

    return sFormatter.format(durationformat, timeArgs).toString();
}

From source file:nl.igorski.lib.utils.network.TransferMonitor.java

public static void monitoredTransfer(Context aContext, ITransfer aTransfer, int aTitle, int aBody) {
    monitoredTransfer(aContext, aTransfer, aContext.getString(aTitle), aContext.getString(aBody));
}

From source file:com.app.common.util.IntentUtils.java

public static void startEmailActivity(Context context, int toResId, int subjectResId, int bodyResId) {
    startEmailActivity(context, context.getString(toResId), context.getString(subjectResId),
            context.getString(bodyResId));
}

From source file:Main.java

/**
 * Show Alert Dialog/* w  w  w  .j a  v a  2  s . c o  m*/
 * @param context
 * @param titleId
 * @param messageId
 */
public static void showAlert(Context context, int titleId, int messageId) {

    showAlert(context, context.getString(titleId), context.getString(messageId));

}

From source file:Main.java

/**
 * Show Alert Dialog/*w w  w  .j a  va 2 s .c  o m*/
 * @param context
 * @param titleId
 * @param message
 */
public static void showAlert(Context context, int titleId, String message) {

    showAlert(context, context.getString(titleId), message);

}