This tutorial will teach you
the basics of how to build an Android app using the Android Studio development
environment. As Android devices become increasingly more common, demand for new
apps will only increase. Android Studio is an easy to use (and free)
development environment to learn on. It's best if one has a working knowledge
of the Java programming language for this tutorial because it is the language
used by Android. There won't be much code used in this tutorial, so I will
assume that you know enough Java to understand or are willing to look up what
you don't know. This will take roughly 30-60 minutes, depending on how quickly
you are able to download and install Android Studio. After using this tutorial
to create your first Android app, you'll be well on your way to a fun new hobby
or possibly even a promising career in mobile development.
Step 1: Install Android
Studio
1. Go to http://developer.android.com/sdk/index.html to
download Android Studio.
2. Use the installer to
install Android Studio following its instructions.
First, you learn how to create a "Hello, World!"
project with Android Studio and run it. Then, you create a new interface for
the app that takes user input and switches to a new screen in the app to
display it.
Before you start, there are two fundamental concepts that you
need to understand about Android apps: how they provide multiple entry points,
and how they adapt to different devices.
Step
1: Create a new project
1. Open Android Studio.
2. Under the "Quick
Start" menu, select "Start a new Android Studio project."
3. On the "Create
New Project" window that opens, name your project "HelloWorld".
4. If you choose to, set
the company name as desired*.
5. Note where the project
file location is and change it if desired.
6. Click
"Next."
7. Make sure on that
"Phone and Tablet" is the only box that is checked.
8. If you are planning to
test the app on your phone, make sure the minimum SDK is below your phone's
operating system level.
9. Click
"Next."
10.
Select
"Blank Activity."
11.
Click
"Next."
12.
Leave
all of the Activity name fields as they are.
13.
Click
"Finish."
Step 3: Edit the Welcome
Message in the Main Activity
1. Navigate to the activity_main.xml
tab if it is not already open.
2. Make sure that the
Design tab is open on the activity_main.xml display.
3. Click and drag the
"Hello, world!" from the upper left corner of the phone display to
the center of the screen.
4. In the project file
system on the left side of the window, open the values folder.
5. In the values folder,
double-click the strings.xml file.
6. In this file, find the
line "Hello world!".
7. After the "Hello
world!" message, add "Welcome to my app!"
8. Navigate back to the
activity_main.xml tab.
9. Make sure that your
centered text now reads "Hello world! Welcome to my app!"
MainActivity.java Code:-
package com.example.firstapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Activity_main.xml
code:-
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
1 Comments
This is nice post i like it nice explain
ReplyDelete