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

by | Nov 18, 2019 | Android, Android for Beginners, Basics | 0 comments

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 create an Android App in Android Studio for beginners?

To create an Android App you will have to follow these steps and your first android app will be ready in 10 minutes.

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 :)

CODING with T

🚀 Supercharge your Flutter skills! Subscribe to my YouTube channel now for mind-blowing coding insights, expert tips, and exclusive content. Don’t miss out!

COURSES

Android firebase app - android app 2022 - firebase android app - bulls rent app - coding with t app - android app
android complete login signup product by taimoor sikander free for any type of android app
Flutter E Commerce App Modern and latest
Flutter Login App UI Source Code - Flutter Complete App - Flutter App Design - Flutter App 2023 - Complete Flutter App 2023
Learn flutter from scratch in 4 hours - Flutter Crash Course - Coding with T

Latest Tutorial

How to create a Custom Appbar in flutter. Custom Appbar Design. Flutter App Design
How to create a Custom Shape in Flutter. Flutter E Commerce app Design. Ecommerce app design Flutter. Flutter clippath tutorial
Bottom Navigation bar in Flutter. Flutter Material 3 bottom navigation bar. How to design background color of Flutter bottom navigation bar. Flutter ecommerce app design
Access Admin Panel, Premium Tutorials, Live Chat, 50% off Codes, and More on Patreon!
This is default text for notification bar