Breaking

Tuesday 12 March 2019

Android Tost Message Example | Android Tutariyal | Tost Example


Android Tost Message Example


Andorid Toast can be utilized to show data for the brief timeframe. A toast contains message to be shown rapidly and vanishes after at some point.



The android.widget.Toast class is the subclass of java.lang.Object class.

You can make custom toast too for instance toast showing picture. You can visit next page to see the code for custom toast.

Tost Class

Toast class is utilized to demonstrate warning for a specific interim of time. After at some point it vanishes. It doesn't obstruct the client association.

Android Tost Example

 Toast.makeText(getApplicationContext(),"Hello Javatpoint",Toast.LENGTH_SHORT).show();  

Another code:


 Toast toast=Toast.makeText(getApplicationContext(),"Hello Javatpoint",Toast.LENGTH_SHORT);  
  toast.setMargin(50,50);  
  toast.show();  


Full Code of activity class displaying Tost

File :- Mainactivity.java




package example.javatpoint.com.toast;  
  
import android.support.v7.app.AppCompatActivity;  
import android.os.Bundle;  
import android.widget.Toast;  
  
public class MainActivity extends AppCompatActivity {  
  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
  
        //Displaying Toast with Hello Javatpoint message  
        Toast.makeText(getApplicationContext(),"Hello Javatpoint",Toast.LENGTH_SHORT).show();  
    }  
}  


OutPut :-



No comments:

Post a Comment