Android 1 – Hello World Android App Example

0
49
digitalample eye
This is the Android tutorials series for Android learners. In this series, we will teach you to guide about to make Hello World Android App.
As you all know Android is a Java-based programming language and Android can help us to develop an application for mobile devices.
First of all, you need to setup Android environment to work. Follow these below links to install and configure your Android studio.

  1. Configure Environmental Variables.
  2. Install SDK for Android
  3. Install Android Studio.
  4. Install JDK & JRE
  5. Create a new project on Android

In this tutorial, we are going to create Hello World Android App through Android studio. After installing your android studio. Now Create a new project on Android, and just run that application on the emulator.

Android 1 - Hello World Android App Example

Now you can just check these below codes and implement them on your android application. Nowadays it’s all files changed now you have to work with content_main.xml and java file will remain same because we are not editing anything.

content_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.satya.myapplication.MainActivity"
tools:showIn="@layout/activity_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>

MainActivity.java

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
}

resources

<resources>
<string name="app_name">My Application</string>
<string name="action_settings">Settings</string>
</resources>

LEAVE A REPLY

Please enter your comment!
Please enter your name here