Java tutorial
//package com.java2s; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class Main { public static void toastShow(String paramString, Context paramContext) { View localView = LayoutInflater.from(paramContext).inflate(getLayoutId(paramContext, "xdw_toast_item"), null); Toast localToast = new Toast(paramContext); localToast.setView(localView); localToast.setGravity(17, 0, 0); ((TextView) localView.findViewById(getResId(paramContext, "xdw_toast_mes"))).setText(paramString); localToast.show(); } public static int getLayoutId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "layout", paramContext.getPackageName()); } public static int getResId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "id", paramContext.getPackageName()); } }