General monitoring Onclicklistener Events, we are all through button button = (button) Findviewbyid (...);
Button.setoclicklisener .... Such a way to achieve.
This period of time to see the major open platform of the demo, found in the XML can actually define a good method name, in the activity to implement the method can be.
<button
Android:layout_width= "70DP"
android:layout_height= "Wrap_content"
Android:layout_centervertical= "true"
android:background= "@drawable/title_btn_back"
android:onclick= "Share_activity_back"
Android:text= "Back"
Android:textcolor= "#fff"
Android:textsize= "14sp"/>
public void Share_activity_back (View v) {
Intent Intent = new Intent (this, mainactivity.class);
StartActivity (Intent);
}
This method can be implemented directly in the activity, and there is no need to define a button to instantiate it, which is much more convenient than the original one.
Implementation of the OnClick event correlation processing method in the Android development layout file