Hello World

HELLO WORLD EXAMPLE - ANDROID


So let us start android programming with android framework using Android Studio. Before we start you just first need to check out that you have set up your Android Development Environment properly. Environment Check.

Now let us proceed with android development with a small example Hello World.


Create Android Application.

Step 1:  Creating simple Android Application using Android Studio. Open Android Studio IDE, 
File -> New-> New Project.

Step 2:  Target Android devices.














Step 3:  Add an Activity.















Step 4:  Customize an Activity. 















After  these  you will have your project screen.















  • The Main Activity file is a java file MainActivity.java this is a actual application file which converts Dalvic executables and runs your Application. This is default file.


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"   
 xmlns:tools="http://schemas.android.com/tools"    
 android:layout_width="match_parent"    
 android:layout_height="match_parent"   
 android:paddingBottom="@dimen/activity_vertical_margin"   
 android:paddingLeft="@dimen/activity_horizontal_margin"   
 android:paddingRight="@dimen/activity_horizontal_margin"   
 android:paddingTop="@dimen/activity_vertical_margin"    
 tools:context="com.example.hss_24.myapplication2.MainActivity">

    <TextView      
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</RelativeLayout>

  • The Layout File is a xml file which helps you to convert your design and change the layout of your Application very frequently. This is default file.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"   
 xmlns:tools="http://schemas.android.com/tools"    
 android:layout_width="match_parent"    
 android:layout_height="match_parent"   
 android:paddingBottom="@dimen/activity_vertical_margin"   
 android:paddingLeft="@dimen/activity_horizontal_margin"   
 android:paddingRight="@dimen/activity_horizontal_margin"   
 android:paddingTop="@dimen/activity_vertical_margin"    
 tools:context="com.example.hss_24.myapplication2.MainActivity">

    <TextView      
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</RelativeLayout>


  • Now run your Application by pressing the green play icon on top of the Android Studio, I suggest you to Create an AVD Create Android Virtual Device

Comments