Use of 1.Activity
When creating an Android project with Eclipse, there is a default XML file Activity_main in the Res/layout directory, where you can set a static layout. In Mainactivity.java, Setcontentview (R.layout.activity_main) is called in the OnCreate method, a layout file is obtained, and an object is generated for each activity in a layout file. We want to set the activity in code, we must set the Id,findviewbyid (r.id.xx) method for activity in the layout file to get the activity we want, and we need to change it down. Once we get the activity object, we can make various settings for it.
2. Use of listeners
Process: A. Use the Findviewbyid method to get the activity object you want to listen to
B. Defining a class to implement a listener interface
C. Generate objects of this class
D. Binding listener for activity that you want to listen to
onclicklistner:public void OnClick (view v) View V represents the activity that triggered the click event, passing the object to the OnClick method, via V.getid () You can tell which activity triggered the event.
Oncheckchangedlistener: For checkbox, checked or unchecked will trigger public void oncheckedchanged (Compoundbutton Buttonview, Boolean isChecked) Boolean variable isChecked can be used to determine whether a check is selected.
Android Learning Notes (i) Activity usage and listener Onclicklistener&oncheckchangedlistener