In Android development, the controls in the layout file have an attribute, which is the onclick, for example:
<button android:id= "@+id/button1" android:layout_width= "Wrap_content" Android:layout_h eight= "Wrap_content" android:onclick= "OnButtonClick" android:text= "button"/> implemented in the corresponding activity onbut Tonclick method, you can implement button binding point-to-click Monitoring events, very simple and convenient. public void OnButtonClick (view view) {Toast.maketext (Mainactivity.this, View.getid () + "", Toast.length_long). Show (); } However, in TextView, this setting is not valid: <TextView / nbsp android:id= "@+id/textview1" android:layout_width= "Wrap_content" android:layout_height= "wrap_content" Android: onclick= "OnButtonClick" android:text= "Large text"/> solution, add Android: Clickable= "true" <TextView android:id= "@+id /textview1 " android:layout_width=" wrap_content " & nbsp android:layout_height= "wrap_content" android:clickable= "true" & nbsp android:onclick= "OnButtonClick" android:text= "Large Text "/> Different controls by default Android:clickableProperty values are different, so it is best to add android:clickable= "true" when setting the android:onclick= "OnButtonClick" of a view other than the button.
Use the onclick attribute in layout files in Android