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

public static String format(Context context, int stringId, Object... args) {
    return String.format(context.getString(stringId), args);
}

From source file:Main.java

public static void showShortToast(Context context, int message) {
    showShortToast(context, context.getString(message));
}

From source file:Main.java

public static void showToast(Context context, int resId) {
    showToast(context, context.getString(resId));
}

From source file:Main.java

/**
 * Display a short toast/*  w  ww  . ja v  a2  s.  c  o m*/
 * @param context to use
 * @param id of the string resource
 */
public static void toast(Context context, int id) {
    Toast toast = Toast.makeText(context, context.getString(id), Toast.LENGTH_SHORT);
    toast.show();
}

From source file:Main.java

public static void showLongToast(Context context, int stringId) {
    showLongToast(context, context.getString(stringId));
}

From source file:Main.java

public static String getString(Context context, String paramString) {
    try {/*  w  ww  .  j av  a  2  s  .com*/
        return context.getString(getStringId(context, paramString));
    } catch (Exception e) {
        e.printStackTrace();
        return "";
    }
}

From source file:Main.java

public static void launchUri(Context context, int resId) {
    launchUri(context, context.getString(resId));
}

From source file:Main.java

public static void showToast(Context context, @StringRes int text, boolean isLong) {
    showToast(context, context.getString(text), isLong);
}

From source file:Main.java

public static void toast(Context context, int strResId) {
    toast(context, context.getString(strResId));
}

From source file:Main.java

/**
 * Shows a (long) toast.//from w  ww.  j  a  va 2 s.  c om
 *
 * @param context
 * @param resourceId
 */
public static void showToast(Context context, int resourceId) {
    Toast.makeText(context, context.getString(resourceId), Toast.LENGTH_LONG).show();
}