About these ads

Aatul Palandurkar

Writing HelloWorld in Android

Posted on: July 29, 2013

Objective :

  • How to write HelloWorld Application in Android?
  • How to write HelloWorld App in Android?
  • How to write HelloWorld in Android?

To create HelloWorldApp follow the steps below :

  • Go to File Menu > Go to New > Click on Android Application Project.

  • In New Android Application Window, enter Application Name as “HelloWorldApp”. Do not change anything else and click Next.

  • While you are in Configure Project Window, uncheck the Create custom launcher icon. Do not change anything else. Click Next.

  • In Create Activity window, click Next.

  • In Blank Activity Window, change the Activity Name to “HelloWorldApp”. Do not change anything else. Click Finish. And your HelloWorldApp Android application will be created.

Here is snapshot of HelloWorldApp project structure :

HelloWorldApp Project Structure in Android

XML Code for UI

File : activity_hello_world_app.xml


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical" >

<TextView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/hello_world" />

</RelativeLayout>

XML code which manages all the string items or labels.

File : strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">HelloWorldApp</string>
 <string name="action_settings">Settings</string>
 <string name="hello_world">Hello world!</string>
</resources>

Java Code

File : HelloWorldApp.java

package com.example.helloworldapp;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class HelloWorldApp extends Activity {

@Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_hello_world_app);
 }

}

After writing your code, to run this snippet you need an AVD (Android Virtual Device) or Emulator. Here is tutorial link which will help you to create AVD so as to run your Android application.

About these ads

2 Responses to "Writing HelloWorld in Android"

Reblogged this on LG Optimus Blog and commented:
Don’t forget Max Battery Booster: https://play.google.com/store/apps/details?id=com.faygroup.maxbatterybooster

Thanks a lot for re-blogging onto your blog.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About these ads

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,143 other followers

Tweets

Follow

Get every new post delivered to your Inbox.

Join 1,143 other followers

%d bloggers like this: