July 19, 2021

How to Make a Button Open a New Activity – Android Studio Tutorial

In this video we will learn, how to open a new Activity from a Button click. For this we will create a new Intent and pass it to the startActivity method.

Example code for this video:

❗ Subscribe to the channel:

⏯ Watch more tutorials:

⭐ Become a channel member for exclusive tutorials and other perks:

㊙ Help translating the videos:

💚 Support the content:

💬 Join the Discord chat:

🎧 Audiobooks and podcasts for programmers:

👶 How to get started with Android development:

📣 Follow Coding in Flow on social media:





Nguồn: https://sam-pointer.com/

Xem thêm bài viết khác: https://sam-pointer.com/cong-nghe/

Related Posts

How to bring back the Start Menu in Windows 8.1 / Windows 8

July 11, 2020

July 11, 2020 37

How To Get The Windows 8 Start Menu Get the Classic Start Menu on Windows 8.1 | Classic Shell Install...

SIMPLE & CHEAP Church Stage Design Ideas [Real Examples]

July 13, 2020

July 13, 2020 21

Church stage design can feel intimidating – especially if you’re a smaller church. But here’s the good news: you CAN...

StringStream in C++ (HackerRank Solution)

July 15, 2020

July 15, 2020 10

Solution for StringStream in C++, one of the most popular HackerRank problem solving questions. Learn how to use StringStream in...

Đánh giá nhanh SSD WD Blue SN550: SSD M.2 NVMe giá tốt hiệu năng bất ngờ!

July 15, 2020

July 15, 2020 2

WD Blue SN550 là dòng SSD phổ thông được đánh giá có hiệu năng/ giá thành rất tốt thời điểm...

【Touhou – 東方】 Stand up apple boy 「Fuling Cat Mark」

July 13, 2020

July 13, 2020 6

♫•Title : Stand up apple boy ♫•Album :キャプリーヌにこいして ♫•Circle: Fuling Cat Mark / フーリンキャットマーク ♫•Arrangement : 谷高マーク ♫•Vocal: 鳴紗 ♫•ZUN...

SSD Samsung 860 Pro 512 vs SM863 bền nhất tốt nhất siêu rẻ của Samsung – Lãng khách

July 7, 2020

July 7, 2020 9

SSD Samsung 860 Pro 512 vs SM863 bền nhất tốt nhất của Samsung – Lãng khách SSD Enterprise là cao...

Ubuntu: How to fix "ssh_exchange_identification: read: Connection reset by peer" error?

July 13, 2020

July 13, 2020

Ubuntu: How to fix “ssh_exchange_identification: read: Connection reset by peer” error? (2 solutions!) Helpful? Please support me on Patreon: With...

YEUAPK RV ❖ Stardew Valley Việt Hóa + Mod Anime [ Bản Chuẩn ] cho Android OS mới nhất 2020

July 11, 2020

July 11, 2020 26

Stardew Valley Việt Hóa cho Android là tựa game nông trại kết hợp yếu tố phiêu lưu độc đáo trên...

Kotlin YouTube: OnClickListener to Start Activity with Intent (Ep 4)

July 16, 2020

July 16, 2020 34

Episode 3: With our RecyclerView almost full designed out, we’re now ready to allow for clickability on our list items....

Sandisk vs WD Green vs Adata vs Kingston vs Crucial SSD BENCHMARK ✔️

July 13, 2020

July 13, 2020 20

#Techno_Focus || #TURN_ON_SUBTITLE \ Description Updated on 06/07/2020 ……………………………………………………………………… // Don’t go for Adata … its may have some heat...

How to repair windows 7 and fix corrupt CD/DVD (tutorial)

July 14, 2020

July 14, 2020 40

How to use windows 7 startup repair by this youtube video tutorial will show you how use Windows startup repair...

Hướng dẫn tải và cài đặt StarCraft II The Complete Collection Full Crack 2019 – Daominhha.com

July 11, 2020

July 11, 2020 5

Tải game StarCraft II The Complete Collection miễn phí Google Drive, Hướng dẫn cài đặt StarCraft II The Complete Collection...

Learn SQL in 1 Hour – SQL Basics for Beginners

July 16, 2020

July 16, 2020 43

A crash course in SQL. How to write SQL from scratch in 1 hour. In this video I show you...

Basico: Aprende a diferenciar los SSD | Western Digital SSD – Proto Hw & Tec

July 13, 2020

July 13, 2020 44

Nuestras computadoras LEGA de venta Aqui: *Correo para cotizaciones de armados de PC* **** proto.tec2015@gmail.com **** **** ventas@highpro.com.mx **** ——————————————–...

Mua Hàng Online Gia Rẻ 500k ssd 120gb Và Cái Kết

July 13, 2020

July 13, 2020 44

Đăng ký kênh miễn phí ( Subscribe free) : Đăng ký kênh phụ dự phòng ae nhé : Pc 20tr...

  • Very Nice and concise video. Well Done!
    I was wondering what code changes would be needed if you had two or buttons on the same page or in a list.
    Thanks for taking the time to develop this.

  • intent intent new intent intent activity intent intent
    bro just use some different words someone like me who is new to java wont get it

  • Upon clicking I get the generic "Unfortunatley, the app has stoped working" error. My repo is different than yours but I've copied your steps:
    Any help?

  • For the button.OnClickListener(), the button shows as expected class or package, how do I resolve it?

  • I had a problem, it says "AAPT: error: resource string/action_settings (aka com.example.myapp:string/action_settings) not found."
    In particulary it's missing the main.xml:4…. I only had content_main and actvity_main… I didn't have main
    what should I do? I didn't use your code, but I needed to make the button open another activity
    Please, help me

  • hii your video is very useful and easy to understand!!

    can i ask a question, so im making expert system on android studio, how can i make the button open another activity? so i can open multiple activitu with just one button

  • package com.example.application.myapplication;

    import android.content.Intent;

    import android.support.v7.app.AppCompatActivity;

    import android.os.Bundle;

    import android.view.View;

    import android.widget.Button;

    public class MainActivity extends AppCompatActivity {

    private Button button;


    protected void onCreate(Bundle savedInstanceState) {



    button = (Button) findViewById(R.id.button);

    button.setOnClickListener(new View.OnClickListener() {


    public void onClick(View v) {





    public void openActivity2() {

    Intent intent = new Intent(this, Activity2.class);




  • For more info on intents and how to pass data from one activity to another watch this:-

  • Hi, thanks for the video first up! I'm having a slight problem though. I try to open another activity having google map in it, and it briefly opens for a second, after which it closes and says "App keeps stopping". What should I do? Please help!

  • I can't edit the activity_main_XML file…even copy & paste also not working inside the file..can u help me pls

  • Uncaught TypeError: Cannot read property 'update' of undefined

    this is the error im facing . the app keeps on crashing as soon as i press the button

  • Sehr gutes Video danke wieder dafür, doch wieso änderst du in der xml Datei das Layout immer in Relative ?

  • This is my xml_main

    app:layout_constraintStart_toStartOf="parent" />

  • I have used but the button desapears when i click on.
    public class MainActivity extends AppCompatActivity {
    ImageSwitcher btn2;
    int mDefaultColor;
    protected void onCreate(Bundle savedInstanceState) {

    mDefaultColor = ContextCompat.getColor(MainActivity.this,R.color.colorAccent);
    btn2 = findViewById(R.id.btn2);
    btn2.setOnClickListener(new View.OnClickListener() {
    @RequiresApi(api = Build.VERSION_CODES.M)
    public void onClick(View v) {

    public void openColorPicker(){
    AmbilWarnaDialog colorPicker = new AmbilWarnaDialog(this, mDefaultColor, new AmbilWarnaDialog.OnAmbilWarnaListener() {
    public void onCancel(AmbilWarnaDialog dialog) {


    public void onOk(AmbilWarnaDialog dialog, int color) {
    mDefaultColor = color;


  • Hi, I wonder the changing of background tint, size, margins of the buttons will affect the function of the button? Cuz I followed what you showed it works at first, but after I changed the background tint and margin all that minor changes it turns out buttons did not show in the emulator…i need help…

Leave a Reply

Your email address will not be published. Required fields are marked *