Skip to content

Instantly share code, notes, and snippets.

@jobinjj
Created April 3, 2019 14:29
Show Gist options
  • Save jobinjj/adf74badc67ad803a3d731ac5766daa9 to your computer and use it in GitHub Desktop.
Save jobinjj/adf74badc67ad803a3d731ac5766daa9 to your computer and use it in GitHub Desktop.
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast,
(ViewGroup) findViewById(R.id.custom_toast_container));
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("This is a custom toast");
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment