Email: Password:       Forgot Password 
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.

Showing Message Box in Android Application

Viewed:  1443 
Posted On:  22/12/2012 21:56:40 
in this article I am going to show how we can use textbox, button, image in Android Application. 

In this article I am going to explain how we can use TextBox, Button and show a message box on click of Button...

In this application I am using a text box to display some text, a button on which click I am showing current DateTime. When we drag text box, button on form then activity_main.xml

image 1.

<RelativeLayout xmlns:android=""
    tools:context=".MainActivity" >
        android:text="Rahul Saxena"
        android:textSize="30dp" />
        android:text="Current Time"
        android:onClick="ClickMe" />  

In <Button Section > see android:onClick="ClickMe" This is the method (ClickMe) which called on button click.

Go to

package com.example.myfirstapp;
import java.util.Date;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends Activity
    protected void onCreate(Bundle savedInstanceState) {
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;
    public void ClickMe(View v)
       Date d =new Date();
       Toast.makeText(this, "Current Date "+ d,


Now to run the application Right Click on MyFirstApp in leftHand pane like in below image...


Image 2.

Simulator is starting up... 


Image 3.

Your application will look like this in
  Android Mobile 


Image 4.

Now click on Button...


Image 5.

         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us