Create an Android App in Android Studio and change text on Button Click

Android, Android for Beginners, Basics

To create an Android App for beginners in android studio you can following the steps in the YouTube video above or you can simply follow the steps mentioned below to create your first Android app based on Android Studio IDE. In this Android Toutorial we will simply create a new android studio app in which we will learn how to create Android App in Android Studio and how to change text on Button Click in Android Studio.

How to Install Android Studio?

Android Studio is Google’s Official Software OR IDE(Integrated Development Environment) to Developed android Apps. Android studio gives us a proper environment for developing and for coding of android apps. Right now their are two language in which android native apps are developed

but most of the apps available in play store is developed in java only, because Kotlin is a new language comes in android development.

Before Jumping to the download of Android Studio please first match the requirements.

Operating system requirements:

Windows requirements

  • Microsoft Windows 7/8/10 (32-bit or 64-bit)
  • 3 GB RAM minimum, 8 GB RAM recommended (plus 1 GB for the Android Emulator)
  • 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE plus 1.5 GB for Android SDK and emulator system image)
  • 1280 x 800 minimum screen resolution

Mac OS requirements

  • Mac OS X 10.10 (Yosemite) or higher, up to 10.13 (High Sierra)
  • 3 GB RAM minimum, 8 GB RAM recommended (plus 1 GB for the Android Emulator)
  • 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE plus 1.5 GB for Android SDK and emulator system image)
  • 1280 x 800 minimum screen resolution

Linux OS requirements

  • GNOME or KDE desktop. Tested on Ubuntu 14.04 LTS, Trusty Tahr (64-bit distribution capable of running 32-bit applications)
  • 64-bit distribution capable of running 32-bit applications
  • GNU C Library (glibc) 2.19 or later
  • 3 GB RAM minimum, 8 GB RAM recommended (plus 1 GB for the Android Emulator)
  • 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE plus 1.5 GB for Android SDK and emulator system image)
  • 1280 x 800 minimum screen resolution

Pre-Requsite

  • The Java Development Kit (JDK)
  • If your system has an up-to-date JDK installed, you won’t need to install it again. The JDK provides tools, such as the Java compiler, used by IDEs and SDKs for developing Java programs. The JDK also contains a Java Runtime Environment (JRE), which enables Java programs, such as Eclipse, to run on your system.

To download the JDK Click Here

To download the android Studio Click Here

Step # 2 : Create a New Project

When you open the Android Studio for the first time to create a new android app. A New screen will appear on which you have multiple options but to create a new Android Studio project you have to select Start new Android Studio Project.

Step # 3 : Start an empty activity

After creating a new project, new screen appears with multiple activities to select from. Each activity provides the facility to do something special. e.g. With an Map activity you can directly see a map on that specific activity ad so on. So for this project we will choose an empty activity because later on we can do what ever we what to.

Step # 4 : Enter project name

In the third screen you will be asked to enter your Project Name, Package Name and Choose the language either Java or Kotlin. From the below mentioned Android Versions we should choose the most minimum version to accomodate all types of Android devices.

Step # 5 : Design the XML file

To design our project you simply have to place two TextView’s and one Button. You can get the code of .xml file from below.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="My First Android App"
        android:textSize="30sp"
        app:fontFamily="cursive"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.099" />
    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="108dp"
        android:text="Before Buton Clicked"
        app:layout_constraintBottom_toTopOf="@+id/btn"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />
    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Click me"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.601" />
</androidx.constraintlayout.widget.ConstraintLayout>

Step # 6 : Add Hooks in Java

To do the coding we need a Java file which automatically created when we create a new activity. So first we need to hook all the TextViews and Button in the Java file.

public class MainActivity extends AppCompatActivity {
    TextView textView;
    Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //Hooks 
        textView = findViewById(R.id.textView);
        btn = findViewById(R.id.btn);
    }
}

Step # 7 : Write OnClick() Method

On the Click Function of our button we want to change the text. So create a simple onClick() Listner.

public class MainActivity extends AppCompatActivity {
    TextView textView;
    Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //Hooks 
        textView = findViewById(R.id.textView);
        btn = findViewById(R.id.btn);
        //Btn click 
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                textView.setText("Button Clicked");
            }
        });
    }
}

Step # 8 : Run Your First Android App :)

Let's Connect

Videos are always a better source for in-depth knowledge. So, connect with me at YouTube.

Download Project

Flutter Login App UI Source Code- How to Create a complete Flutter app - Flutter education app - Flutter app UI Design - Flutter Course - Flutter Complete App 2022
Dashboard Source COde - Dashboard design in flutter - flutter dashoard - flutter app design 2022 - Flutter UI - Flutter homepage

Latest Courses

Flutter Login App UI Source Code- How to Create a complete Flutter app - Flutter education app - Flutter app UI Design - Flutter Course - Flutter Complete App 2022
Learn flutter from scratch in 4 hours - Flutter Crash Course - Coding with T

Latest Tutorials

Flutter Profile page UI Design - Flutter app design 2023 - Profile Screen Flutter UI - Flutter 2023
Flutter Firebase phone authentication - Firebase Phone auth tutorial in flutter - Flutter Firebase phone number authentication 2022
Firebase Authentication in flutter - Flutter firebase authentication 2022 - firebase auth tutorial 2022 - firebase flutter auth
How to setup firebase in flutter 2022 - Flutter firebase setup
Dashboard Source COde - Dashboard design in flutter - flutter dashoard - flutter app design 2022 - Flutter UI - Flutter homepage

Join Our Mailing List

Join our mailing list to receive the latest, Free Courses, Video Tutorials, free codes and updates regarding Tutorials and services. You will also start getting coupons on the related services.

You have Successfully Subscribed!

FLUTTER APP

Learn Flutter App development from scratch. Create LOGIN APP that can be used with any application which requires Login Sign Up functionality.

You can watch it on YouTube or read and get source code from Blog Post.

You have Successfully Subscribed!