GTU DE Sem6 – 3360704 – 1 – Create Hello World application That will display “Hello World” in the middle of the screen in the red color with white background

      Comments Off on GTU DE Sem6 – 3360704 – 1 – Create Hello World application That will display “Hello World” in the middle of the screen in the red color with white background

GTU DE Sem6 – 3360704 – 1 – Create Hello World application. That will display “Hello World” in the middle of the screen in the red color with white background

DE Sem6 - 3360704 - 1 - Create "Hello World" application

 This Android HelloWorld Example shows how to start with Android Development. basically, you need to create new Android Application with Eclipse or ADT. Then You will get default one Activity with it. Now you need to add one TextView on your Layout. for the same, you need to goto res/layout/activity_main.XML file and add the code that’s displayed as follow. then goto code that means in src/package/MainActivity.java and writes down following code to get the exact output.

Jump to Practical 2

Android is popular mobile operating system, You have reached to the android tutorial where you can learn android programming with easy to learn the method. I have already written many articles on android programming, For more check out the list of links at the end of an article.

If you are expert in android then you might be interested in android tips and tricks.

Here is the android sample code for hello world example which can help you to start android application development with easy to learn steps.

File:MainActivity.java

/*
Mobile Computing and Application Development : 3360704

GTU DE Sem6 - 3360704 - 1 - Create "Hello World" application. That will display "Hello World" in the 
middle of the screen in the red color with white background
*/

package gtu.de.mcad.ex01;

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

public class MainActivity extends Activity {

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

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		
		return super.onOptionsItemSelected(item);
	}
}

 

File:activity_main.xml

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

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Hello World"
        android:gravity="center_horizontal|center_vertical"
        android:textColor="@color/red"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

 

FileName: color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="red">#FF0000</color>
    
</resources>

 FileName:AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="gtu.de.mcad.ex01"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

 

Output

DE Sem6 - 3360704 - 1 - Create "Hello World" application.

 

Check out android tips and tricks, most useful to speedup you task.