How to make android apps
In this page, you will know how to create the simple hello android application. We are creating the simple example of android using the Eclipse IDE. For creating the simple example:
- Create the new android project
- Write the message (optional)
- Run the android application
1.Creating Android Application
The first step is to create a simple Android Application using Eclipse IDE. Follow the option File -> New -> Project and finally select Android New Application wizard from the wizard list. Now name your application as HelloWorld using the wizard window as follows:Next, follow the instructions provided and keep all other entries as default till the final step. Once your project is created successfully, you will have following project screen −
2) Write the message
For writing the message we are using the TextView class. Change the onCreate method as:- TextView textview=new TextView(this);
- textview.setText("Hello Android!");
- setContentView(textview);
- package com.example.helloworld;
- import android.os.Bundle;
- import android.app.Activity;
- import android.view.Menu;
- import android.widget.TextView;
- public class MainActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- TextView textview=new TextView(this);
- textview.setText("Hello Android!");
- setContentView(textview);
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.activity_main, menu);
- return true;
- }
- }
3) Run the android application
To run the android application: Right click on your project > Run As.. > Android ApplicationThe android emulator might take 2 or 3 minutes to boot. So please have patience. After booting the emulator, the eclipse plugin installs the application and launches the activity. You will see something like this:
No comments:
Post a Comment