Also in the Android primer, write something to summarize the record, improve efficiency, promote learning.
(Some places will be harmonious, so take it apart, like on click)
First of all, learn about several common implementations of button classes in Android: The first: Anonymous inner classes are recommended as event listeners for this method.
Second: The inner class acts as the third event listener: Activity itself as an event listener is concise but the program structure is a bit messy.
Fourth: Bind directly to the tag in the layout file you need to specify the on Click Property, whose Han Der () method needs to be defined in the. java file as follows: The corresponding Java code is as follows: 1. Click the button to display the text layout file code as follows: The corresponding Java code is as follows:
There are several problems in the implementation process, the first is said "SetOn Clicklistener" () ... the type view is not applicable. And so on, add import "Android.view.View.On Clickistener" in the back; just add the import android.view.View; The second is to say must implement the inherited abstract method ..., add the import Android.view.View later;
The click button Effect of Android development