Adding code to a Button Click in Android Studio (Java )

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025
  • To define the click event handler for a button, add the android onClick attribute to the Button element in your XML layout. The value for this attribute must be the name of the method you want to call in response to a click event. The Activity hosting the layout must then implement the corresponding method.

ความคิดเห็น •

  • @ernestodidierartisteintern5365
    @ernestodidierartisteintern5365 ปีที่แล้ว +1

    YOU BE BLESSED THANK

  • @salmabaig3280
    @salmabaig3280 3 ปีที่แล้ว +2

    Very clear explanation of onClick method. Thank you!

  • @alexmeade47
    @alexmeade47 4 ปีที่แล้ว +12

    Wow thank you so much. Coming from visual studio, I found android studio to be really annoying to learn. I don't like it one bit. You've helped me a lot with this vid.

  • @matt-i3r6w
    @matt-i3r6w 4 ปีที่แล้ว +6

    Why they have to make it a pain to add a click event

  • @francorios1276
    @francorios1276 3 ปีที่แล้ว +2

    and to add more codes in the same text view from 2 or 3 buttons?? can you help me bro?
    Like 4 buttons and each one say a word. Press 1, later press the 2 and 3 etc and this adding word to word in the textview you know??

  • @macsmarketing5653
    @macsmarketing5653 5 ปีที่แล้ว +3

    I cant change the position of the button.

  • @johnymadrita9065
    @johnymadrita9065 2 ปีที่แล้ว

    Hi. How to write a function that clicks at x = 100, y = 100 on a smartphone in android studio? Without touching the screen.

  • @nethmal1204
    @nethmal1204 4 ปีที่แล้ว +4

    Thanks ❤Really helpful 💪

  • @MaestroVarela
    @MaestroVarela 2 ปีที่แล้ว

    Is it possible to call a method in another Activity different from main?

  • @lifedreamtv
    @lifedreamtv 4 ปีที่แล้ว +3

    Thank you! How can apply this to change the text in another Activity?

    • @VladVoytenko
      @VladVoytenko  4 ปีที่แล้ว +1

      you have to start new activity by intent

  • @MovieMoments-Erz
    @MovieMoments-Erz 3 ปีที่แล้ว +2

    ty so much:)

  • @dunghoang5728
    @dunghoang5728 3 ปีที่แล้ว +1

    Hi guy, Can you support me create new button by java code? I try to create but I can't change size and position of new button in mainActivity.java
    Thank You very much

    • @starkendeavours7072
      @starkendeavours7072 2 ปีที่แล้ว

      Button can be created in ActivityMain.xml not in Java file.

  • @bhartirajput5535
    @bhartirajput5535 3 ปีที่แล้ว

    Poor