How to create an onClickListener for multiple buttons in Android Studio

Поделиться
HTML-код
  • Опубликовано: 7 фев 2025
  • In this video, you will learn how to set up an onClickListener for multiple buttons in Android Studio. Knowing how to do this can save lots of time and code.
    Android Studio is a great platform for creating apps that can be deployed on the google play store. If you're new to the series I'd go and check out the Android Studio Playlist. There, you will be able to see how to create basic apps so you can become a developer.
    Check out the Android development playlist for more videos like this!
    • Android App Developmen...
    #androidstudio #appdevelopment #PracticalCoding

Комментарии • 26

  • @alexrapp7728
    @alexrapp7728 4 года назад +3

    You're a really big help. I know it takes a lot of time and energy to make these types of videos but just know your doing a great thing helping aspiring coders like myself to figure out more efficient ways to code. I hope this channel grows big one day!

    • @PracticalCoding
      @PracticalCoding  4 года назад

      Thanks, I appreciate the compliment. It's always good to hear that people are actually getting value from my videos.

  • @HUY-hd5hf
    @HUY-hd5hf 11 месяцев назад +5

    when i use: case R.id.button1, I got an error says: "constant expression required", how do i fix this?

  • @JohnFogarty-p2y
    @JohnFogarty-p2y 10 месяцев назад

    This is a wonderful video with a super instructor. I received the same “constant expression required” issue. Unfortunately, the new Studio releases ruin prior program code. Commenting out the switch statement showed me that the id's entering the method matched those of the cases. I removed the interface and its method with the switch statement and entered the five buttons with their “onClicks” individually to watch the program run.

  • @samuelattaantwi3953
    @samuelattaantwi3953 2 года назад

    Thank you very much, a great tutorial

  • @jesterjohnsantiago4288
    @jesterjohnsantiago4288 2 года назад

    thank you men it helps me thank you for your help sending like

  • @ydvisual5530
    @ydvisual5530 4 года назад

    Thanks, that helped a lot. I havent done Android for a long time; this was a good refresh too , thanks!

  • @nightShiftMares
    @nightShiftMares 2 года назад

    Thank you, I was running myself around in circles for an hour here

  • @ghitaelfilali335
    @ghitaelfilali335 3 года назад

    Thank you

  • @s.g.9723
    @s.g.9723 2 года назад

    Wow. Huge help.
    Would I be able to link an onClickListener the same way to a button i.d that I have defined in my index.html but it’s not defined in my layout xml?

  • @AA-tp4si
    @AA-tp4si 2 года назад

    How can we append instead of just setting the text with setText method. Thanks in advance.

  • @samuelattaantwi3953
    @samuelattaantwi3953 2 года назад

    please can it work for all widgets ?

  • @HarjotSingh-xg7qw
    @HarjotSingh-xg7qw 3 года назад

    Thanks a lot bro :)

  • @raj360d
    @raj360d 3 года назад +3

    There is a warning in case label: Resource IDs will be non-final in Android Gradle Plugin version 5.0, avoid using them in switch case statements

  • @digidianne3302
    @digidianne3302 3 года назад

    hey i want to ask, can i change that textview to new activity? like if i click each of the button it will brings the user to the new activity.
    thank you if you reply to this

    • @PracticalCoding
      @PracticalCoding  3 года назад +1

      Yeah, you should be able to swap over to a new activity by creating an intent that can load a new one.

    • @RasikaVirkar
      @RasikaVirkar 2 года назад

      @@PracticalCoding can we have a code or reference video for this ?

    • @rajwali9657
      @rajwali9657 2 года назад

      case R.id.button1:
      Intent intent = new Intent(getApplicationContext(), Activity1.class);
      startActivity(intent);
      break;

  • @ghadarashwan8687
    @ghadarashwan8687 2 года назад

    Can you help me🙂 i want contact app project

  • @mandyronald8187
    @mandyronald8187 2 года назад

    Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements

  • @narottamsonsathi3784
    @narottamsonsathi3784 4 года назад +1

    Don't have any questions.......but I'm trying learning Android Development from ladt two months......but still not able to implement SetOnClickListener.......in Java class.
    I'm just frustrated

    • @PracticalCoding
      @PracticalCoding  4 года назад +1

      If you want, you can put the code you're using for the onClickListener in a comment and I can take a look at it.

  • @liliyapolibinskaya7399
    @liliyapolibinskaya7399 3 года назад

    hello