Summary of how to use android:onClick in Android layout
The Android:onClick="..." property in Android layout sets the specified method to be called from the context when clicked. The value of this property is exactly the same as the method name to be called. Generally, in Activity, you can define a function that meets the following parameters and return values and specify the method name string as the attribute value:
public void onClickButton(View view) android:onClick=“onClickButton”
Functionality is similar to Button's listener.
android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/btn_style_green" android:text="Log in" android:onClick="welcome_login" />
/*In this example, the Button listener is not used to monitor the button action. Click the button login button to call the following method. */
public void welcome_login(View v) { Intent intent = new Intent(); (,); startActivity(intent); }
The above is a detailed explanation of the example of android:onClick in Android layout. If you have any questions, please leave a message or go to the community of this site to communicate and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!