Hello World !! First App in Android

Yeah..!! Now its time to make our first android application. Before we start with it you have to set up Android Studio, well we have all set up Android Studio in last post. If you are first at here go to my post Getting stared with Android Studio.

Let’s make project. Go to File->New->New Project and follow same instruction from last post and complete the project. You will see main two files like below.

activity_main.xml :  In this file we have to make our UI design for app screen. This is a layout file for contain all component such a like button, textview etc.
MainActivity.java : In this file we have to make our java code for particular UI screen to handle our action or listener of component.

Now change in both files like below code.


This file is located in res/layout/activity_main.xml. If its not created then right click on layout folder and create new file. This is our UI screen of app. Here RelativeLayout is a type of layout in android which is discuss in our next session. Layout contain and arrange all component as per its properties. TextView is a Widget of android like Label in other language.  There is a all components have their own attributes. Here android:layout_width, android:layout_height is the attribute of components to demonstrate width and height of them.


Here MainActivity is our class and we have to extends Activity. As the Android application launches Activity instances, we have need to implement your own activity. In Java, it is done by extending the original Activity class. setContentView() function declare that this class Set the activity content from a layout resource. In short which layout is show when this class is created is done by this function.

Run Application

Now its time to run our first application. So first start your Emulator or connect real device and go to Run->Run ‘app’ or press green Play Button. Then a device chooser popup show, select device and after few seconds your application run.

Note for real Device : If you use your device for first time then you have to enable USB debugging in Developer Option in Settings. For old device go to Settings-Developer Options-> Enable USB debugging and for new devices Setting->About Phone-> Press 5-7 time Build Number. Then Developer Option show in your settings, go and enable debugging.

Our output will look like below…..


Congratulation you have create your first app in Android world…!! It’s time to coffee. Now take little rest and go to next tutorial of TextView in Android.

Download Full Code.

(Visited 401 times, 1 visits today)