Skip to main content

Implement Custom Toast In Your App Using Sketchware

Implement Custom Toast In Your App Using Sketchware




In this tutorial I will show you how to implement custom toast.Its very easy and simple.
Follow the steps ....



1)Create a  new project in Sketchware. Add a Button

Screenshot is given Below


            



2)Add a New Custom View.In the custom view add a Linear Layout. Inside the LinearLayout add a Textview.

Screenshot is Given Below


                                    



                                    


3) Now go to the logic area. You will see two events.
onCreate & Button:button1 onClick.


                                    



Click on Button:button1 onClick . In this event add an add source directly block.

Add the following code inside add source directly block


                                          




View layoutValue = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom, null);
TextView textview1 = (TextView) layoutValue.findViewById(R.id.textview1);

textview1.setText("Hello Everyone ");

     
                Toast toast = new Toast(getApplicationContext());
                toast.setDuration(Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
                toast.setView(layoutValue);
 toast.show();



Below are some screenshots .You can Refer them.
                          


4) Now Run the app.The app will display a custom toast on button click.





I hope this tutorial was helpful to you.If you have any doubts you can comment below.

Video tutorial is available on Youtube! 
Link  

Comments

Post a Comment

Did you like this tutorial ?