I'm having the same issues getting a custom toast class for reuse in any activity.
I get a null pointer exception or a invoke findviewbyid method error no matter what I try. please help
class Toaster extends Activity {
Toaster(Context context, String message) {
    {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup)context.findViewById(R.id.toastroot));
        TextView text = (TextView) layout.findViewById(R.id.toasttext);
        text.setText(message);
        Toast toast = new Toast(context);
        toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(layout);
        toast.show();
    }
}}
 
     
     
    