Hello Everyone. This tutorial will help you to build your first basic Android app ie to display Hello User when the app runs.
It's not at all difficult to develop this, but still for those you are new in programming Android, it will be quite helpful for them to start with.
Prerequisites :
1. Android Studio
2. Basic Java and xml knowledge will be helpful.
Creating Project :
1. Open Android Studio.
3. Select the Minimum SDK version you want this app to support. Always choose the lowest SDK so that your app runs on all of the Android Versions. Let other options be unchecked. Click on Next.
It's easy to design as it has the drag and drop option where you can drag the various widgets available and use it in your app. You will notice that by default TextView is present in the file. And its code is
Congratulations for your first app. Now run the app, and it will display Hello Users, My First Android App.
1. Android Studio
2. Basic Java and xml knowledge will be helpful.
Creating Project :
1. Open Android Studio.
2. Click on Start a new Android Studio Project. New Dialog Box appears, provide the Application name. Here I will provide Application Name as 'MyFirstApp'. Company domain is usually the reverse of our website ie com.yourcompanyname , but you can provide anything you want.
Package name is the unique name that will uniquely identify your project. Click on Next.
Package name is the unique name that will uniquely identify your project. Click on Next.
4. This Dialog box shows various templates that you can add to your app. For this , we will select Blank Activity. We will study the other templates later.
5. Provide the Activity Name and layout name. or else let it be by default. Click Finish.
Congratulations! Your Project has been created and now its time to change its content.
Open activity_main.xml. It's a layout file where you will design the UI for your app. Basic xml knowledge will be an added advantage.
It's easy to design as it has the drag and drop option where you can drag the various widgets available and use it in your app. You will notice that by default TextView is present in the file. And its code is
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" />
android:text is the tag in which you will provide the text you want to display. It takes "@string/hello_world" ie it points to another file in which your text is present. So now go to values -> strings.xml.
Here you will notice various strings. Make sure your strings matches to the above snippet. Save the file. Now lets have a look at the java code.
setContentView is the method in which you set the layout file you want this activity to display. Make sure your code matches to this. Thats it.
Congratulations for your first app. Now run the app, and it will display Hello Users, My First Android App.
No comments:
Post a Comment