How to Toast in Android – UI Widget

Posted on .


Toast in Android is something in  which developer can see their result’s ,ouput’s . lets code ….

1). First take Button in  activity_main.xml . After Taking Button in xml file go for file .

2) .

package androidarena.simpletoast;

import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

	protected void onCreate(Bundle savedInstanceState) {
		Button b = (Button)findViewById(;
		b.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Toast.makeText(getApplicationContext(), "WOOOOh !!!! My TOAST IS WORKING", 5000).show();

	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(, menu);
		return true;


Output – toast output   For more queries and tutorials visit my other tutorials and do comment and post here 🙂 happy coding :p

One thought on “How to Toast in Android – UI Widget

Leave a Reply

Your email address will not be published. Required fields are marked *