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

  1. How is your site in google search??

    ReplyDelete
  2. how i can implemet on click in this toast?

    ReplyDelete
  3. Loading the questions from a JSON array and removing each one after pickQuestion runs is a neat way to avoid repeats. A small alternative: shuffle the ListMap once at the start and step through it, which skips the random-index logic. I'm planning to adapt this for a vocabulary quiz – word games like Bookworm Deluxe show how far a simple word mechanic can go.

    ReplyDelete

Post a Comment

Did you like this tutorial ?

Popular posts from this blog

Add Edittext Inside Dialog Box

Add Edittext Inside Dialog Box If you haven`t yet watched the video... Watch  it right  now!!! The code used in the above video is available here. final EditText edittext1= new EditText(MainActivity.this); LinearLayout.LayoutParams lpar = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); edittext1.setLayoutParams(lpar); dialog.setView(edittext1); textview1.setText(edittext1.getText());

Create Custom Popup Window using Sketchware

Create Custom Popup Window using Sketchware Refer the video below if  you get stuck.  1) Add a custom view named window.You can name it according to your wish.  2)Design your popup window.  2) Now, In the logic section,In OnCLick event of button.Add the following  code Create a view View popupView = getLayoutInflater().inflate(R.layout.window, null); Popup window  final PopupWindow popup = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); Initialize  Button b1 = popupView.findViewById(R.id.button1); Button b2 = popupView.findViewById(R.id.button2); OnClickListeners b1.setOnClickListener(new OnClickListener() { public void onClick(View view) { //below code will dismiss the popup window popup.dismiss(); } }); b2.setOnClickListener(new OnClickListener() { public void onClick(View view) { popup.dismiss(); } }); Show the...

Enable Downloads In Your Web Browser

Enable Downloads In Your WebBrowser Latest Tutorial..! 1) Create a new Web Browser   project in Sketchware      Below are some tutorials regarding this topic.      Please watch these tutorials . These tutorials will help you in understanding the topic. Part 1 Part 2 Part 3 3) Export the project which you have created in Sketchware to AIDE or Android Studio 4) Navigate to AndroidManifest.xml and add the following permission <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 5) Now Open MainActivity.java or the Java File where you want to add the Download Listener      and add the following code         webview1.setDownloadListener(new DownloadListener() {                       @Override          ...