Android Button Onclick

后端 未结 9 2051
猫巷女王i
猫巷女王i 2020-11-29 03:41

OK I\'m new to android dev\'s and Java, so I\'m having problems with on click method here\'s my code. I know I\'ve gotta be close, thanks in advance. All I want my button to

9条回答
  •  暖寄归人
    2020-11-29 04:35

    It would be helpful to know what code you are trying to execute when the button is pressed. You've got the onClick property set in your xml file to a method called setLogin. For clarity, I'd delete this line android:onClick="setLogin" and call the method directly from inside your onClick() method.

    Also you can't just set the display to a new XML, you need to start a new activity with an Intent, a method something like this would be appropriate

     private void setLogin() {
    
     Intent i = new Intent(currentActivity.this, newActivity.class);
     startActivty(i);
    
     }
    

    Then set the new Activity to have the new layout.

提交回复
热议问题