Java tutorial
//package com.java2s; import android.content.Context; import android.support.annotation.NonNull; import android.widget.Toast; public class Main { public static void showToast(@NonNull Context context, @NonNull String text) { Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); } public static void showToast(@NonNull Context context, int resId) { Toast.makeText(context, context.getResources().getText(resId), Toast.LENGTH_SHORT).show(); } }