askIT

Android Toast message to user

You can send a message to the user with the Java command toast. Suppose you are writing an email and then quit the e-mail application. You would think that the email is stored as a draft. With Toast you can actully send a message to the user saying that the email was stored.

melding_til_bruker_via_toast.jpg
Toast: The Toast message.

Toast example

Toast.makeText(this, "Email saved as draft", Toast.LENGTH_LONG).show();

MainActivity.java

package com.nettport.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);

                Toast.makeText(this, "Email saved as draft", Toast.LENGTH_LONG).show();
        }
}

Add comment

avatar_blank_60.png

Comment:

Name:

Email:

Comments

No comments yet. You can be the first one to comment. Just write your comment in the form and click on the submit button.