How To- Code a Style Definition Android Tutorial '
Prev Page How To Code Styles and Customize a Style Definition This Page Coding a Java page to Implement a Simple Text Toast Message

Next Tutorial Coding Android Resource Identifiers

If you are just arriving at this page; and you are not familiar with with creating Android Apps, we suggest you begin with our tutorials: Coding Android App Pages and How To Create a Simple App in Android

From there follow along with each tutorial lesson and learn this tutorial - viewid.

Each interactive type tutorial shows you how to create your app for the tutorial code topic: with complete example code to do so. Learn the code pages easily with photos.

We are using AIDE, to create these tutorial apps on our 8.9" tablet with android version 4.2.2; using the Android Java XML programming language.

We are using the AIDE coding editor to code our pages; and then to Create - RUN our apps. AIDE is a SDK coding environment for android devices like a tablet or smartphone. AIDE has a free and paid version. The paid version is required if you want to create Java/xml template apps; and add a 'keystore' to your App. With a keystore, you can publish it to the market places like Google and Amazon.
Once you create your apps code pages, you need to RUN the app to build your apk package; then you INSTALL it on your tablet or smartphone. As of October, the paid version of AIDE is about $20 canadian.

You can also create; RUN your apps using the code in these tutorials, with Android Studio. Android Studio is for desktop computers. Choose Java XML as the programming language. Android Studio is free to install and use; and has helpful guides.

Complete Example Codes are available for each of our tutorials. With these example codes you can make a functioning android app in either AIDE or Android Studio.
Learning To Code Java Pages

For this tutorial, we are going to learn how to code a java page, the; so we can add a simple text message using the Toast Method to our View.

We are going to create a new app for this tutorial, and name is - AndroididToast

Where Code is Coded

This app will also have some text added(wording) so we will use our strings.xml file, for the text we add, and we also keep the 'app name' string. The app name is at the top of your screen next to the little green icon.
All string names are coded in the strings.xml file at res/values of the AppProject, and reference to the string name is made in the TextView element.

We will be adding some code to our layout page, main.xml, which is at res/layout/main.xml, our Button element, and a TextView element.

We will be adding some code to our java activity page, which is which is at src/com/acw/learntoast/

Creating Our New App
Create a Android app, choose java xml programming language

Open AIDE, Select New Project, from the left menu, or center menu hierachy of files; and do the following:

Choose HELLO WORLD example app template(java/xml);
For app name; type AndroididToast

For app package name type: com.acw.learntoast

Click Create

Now your new app has been created with the name 'AndroididToast'.

This name will show on the left menu hierachy in AppProjects within AIDE.

To open your app just click on the app name(AndroididToast) on the left menu; then browse to, the androidmanifest.xml file at bottom of files, double click to open it. The file now shows in the AIDE coding editor.

To view A FILE do either: from right menu choose FILES or GOTO, this will show the apps files along the top of editor, dropdown, and left side menu. After editing a file, SAVE it, right side menu, choose SAVE.

Just double click a file to open it in the coding editor. Once file is opened they also show as tabs at top of editor. Just click file name to open it in the code editor.

view files in coding editor AIDE

To return to prev folder, just click on ORANGE colored FOLDER at top of files hierachy left side menu; to return to AppProjects (where you can see all apps you created) just click orange folder till you see AppProject, or from dropdown menu right side, or middle editor, choose, Show - View All Projects.

Code the Strings.xml
We will add one line of text

"Use Toast Method To Display Text". We will name our string, learntoast, and type the text as shown.
coding a toast android, strings code

Our strings.xml file also has another string, our app_name,AndroididToast, which we will leave in the strings.xml as this is the name that shows at top of view and is required.

Once the text is added to the strings.xml file, save the file.
We will make reference to our string in our TextView element as shown here.

How To Implement a Toast Message Using XML(main.xml) and Java Code(
image of app, coding a toast message
In our strings.xml file we code our text for the app view as shown in the code in this image.
The code for the button using onClick, GoButtonClicked, is how we link our Button element to our java code.

coding a toast android, main.xml code

At the top of our code you see our app package name.

We link our xml page to our java code using the setContentView code as seen in the code in this image. R.layout.main; R. means (the resource) layout (means the layout.xml page) and main means: main.xml.
coding a toast android, java code

After copy pasting the code into the appropriate pages: strings.xml, main.xml, and Save each page.

In this tutorial, we learned how to code a toast message in our apps first page (1st activity). We know that when we clickon the button the toast message will show near the bottom of the app screen.

The duration of the toast message(time it remains visible in the view) is coded with one of two attribute values; either the Long which we used, and the other value you can use is Short.

You can also have the Toast Message appear anywhere within your app's view, by addng some additional code to our Toast code. Learn about coding these and additional Reading on 'Toasts", at the Android Developer website.
View Toasts Code At Android Developer Website


You can get the code from this tutorial from our EXAMPLE CODE section on this page. You can add the code easily to your apps coded pages using copy/paste. Just delete the code that's in your main.xml,, and strings.xml files and replace it with the code from this tutorial. Save each page after pasting the code.

We also included the androidmanifest.xml file, however, this page only needs to be coded when adding certain functionalites or themes to your app. For this tutorial we did not need to change or add code to it.

Additional Reading on Creating a Toast Message at Android Developer website
Gohere and Reading on android:id value, and Accessing Resources in Code
Coding Resources android:id in layout file How Tos - Accessing Resources

EXAMPLE CODE - Code For This Tutorial

JUST USE YOUR MOUSE to copy the code for this tutorial App Name is 'AndroididToast - located at AppProjects/AndroididToast in AIDE, open the AIDE app, then open App Projects, THEN select the 'AndroididToast', app from your files hierachy(left menu); then click on any file from the app, like strings.xml Make sure at top of page, the app name 'AndroididToast' is there next to AppProjects like so: AppProjects/androidIdToast, then you know you have the proper App.

Once a file is in the editor, you can edit, save it, then RUN your APP, install, Open your app.

Make sure you SAVED EACH PAGE, before you RUN your code. SAVE, RUN, INSTALL, OPEN, your AndroididToast App. Once it has been installed on your tablet, you can open it Simply by Clicking on the Android little green App Icon,with the wording 'AndroididToast' on your tablet. It will be with your other installed apps.

If you make further changes to this App, you need to SAVE, RUN, UPDATE, INSTALL, OPEN the app.

Example Code:
Use Mouse To Copy Paste the Code

This free script provided by
JavaScript Kit

Share This Page

AIDE for creating Android Apps on your tablet or cell phone(android).
Free and Paid - with Free create android Java/xml template apps and couple free android lessons. With paid some lessons included, create android Java/xml template apps; and create a keystore for your app. With a keystore you can publish your app at markets like Google.
GoTo Aide

ANDROID STUDIO - for creating Android Apps on your desktop computer.
Free to Install and Use
GoTo Android Studio Learn more - Android Studio

The Java XML files we code(example codes) and the Android Apps we create in our Free Tutorials are compatible with Android Studio and AIDE. Just choose Java XML as your Programming Language.

The Google Play Store has thousands of Free Apps for Android Programming

Do A Google Play Search
"Learn Android, Learn Android Java, Android Programming, Android Development, Code Example For Android Programming, Android Tutorials with Code , Make An Android App Java XML"

You May Like:
Make Sushi Rolls Taste World Wines Flavours and Aromas

Java XML Android
The Coded App Pages
Beginners Article
About Our Tutorials
Coding androidmanifest.xml
Coding main.xml
Coding strings.xml
Coding drawables

Java XML Android
Learning To Code
Create A Simple
Android App

Change App Icon
Add Text and Style
Add Buttons To App
Placing Text
in Buttons

Change View
Background Color

Change Screen

Add Image to
Activity View

Add Horizontal
Scroll View

Add a Frame Layout

How to Add Themes
To Your App

How To Code
Customized Styles

Code a Toast Message

Coding Resource


How To Code Screen Orientation
Clickable Button To URL
Image Button with Selector
Linear Layout with weight attribute
OnClick Displays Message
Screen Density - Coding Practices

and Courses
AIDE - for tablets
Android Studio -for computers
Android Studio Course - Paid
Java Programming Course - Free
Git Hub Course - Free

Code Canyon Paid From $1(can buy individually) Free and Paid From $1 (can buy individually)

All images on this page are copyrighted material.
Images used for the purpose of these tutorials and designated as such and made available for download must not be used for any other reason except for these tutorials.

APP Marketplace
Launching Your Android App
How To Be Successful

Android App Libraries
What are they and how
to implement them

How To Implement ScrollView

What is a WebView
View all Articles

From The Web:

How To Add Your Google Key
To Manifest.xml
Web Article

How To Sign Your APK Web Article

Google Developer Console
Create Account Submit Your App
Web Article

Amazon App DRM - APK KEY
Amazon Developer Portal
Create Account - Submit Your App

With Ads - How To - Free Course

Follow Us On Twitter