Getting Started with Android Programming
When ever i start with new programming language i always start with getting a popup box or alert box. So in this tutorial will see how to get a popup message in an android application.
Here are some pre-requisites that are required for running an android project:
In this project we will be creating a TOST(a popup message) to display "Hello World".
One of the most easy part in android, you may look at the code below:
The above code will display a small popup message on to the screen.
You first need to create an Activity and a class associated to the activity, So on create of this method you may write the Tost code.
Thats it guys ... you have started writing code in android. Soon will post how to setup development environment for android.
Android-SDK
ADT
Eclipse
Basic Java Knowledge
In this project we will be creating a TOST(a popup message) to display "Hello World".
One of the most easy part in android, you may look at the code below:
Toast.makeText(--APP CONTEXT--, --Text-- , --Length--).show();
The above code will display a small popup message on to the screen.
You first need to create an Activity and a class associated to the activity, So on create of this method you may write the Tost code.
package com.example.demoui;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import android.support.v4.app.NavUtils;
public class NewUI extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_ui);
Toast.makeText(getApplicationContext(), "Hello World", Toast.LENGTH_SHORT).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_new_ui, menu);
return true;
}
}
Understand in detail about the function :
--App Context-- : The context of the Application/Activity.
--Text-- : The text your need to display on the screen.
--Length-- : For how long the text should be displayed (Toast.LENGTH_SHORT, Toast.LENGTH_LONG).
Thats it guys ... you have started writing code in android. Soon will post how to setup development environment for android.