Ahmed_Zouhir

Create custom toast [Sketchware /Code] by Ahmed Zouhir

Jan 25th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. //please help me to improve my channel
  2. //subscribe for more videos 😁
  3. LayoutInflater inflater = getLayoutInflater();
  4. View layout = inflater.inflate(R.layout.custom,
  5.                                (ViewGroup) findViewById(R.id.custom));
  6.  
  7. TextView txt = (TextView) layout.findViewById(R.id.text);
  8. txt.setText("Hello! This is a custom toast!");
  9.  
  10. Toast toast = new Toast(getApplicationContext());
  11. toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
  12. toast.setDuration(Toast.LENGTH_LONG);
  13. toast.setView(layout);
  14. toast.show();
Add Comment
Please, Sign In to add comment