1. First copy the Afinal.jar file to the Libs folder in the project
2. Let mainactivity not inherit the activity of the system, but inherit finalactivityPublic class Mainactivity extends Finalactivity
3. Change the protected of OnCreate method in mainactivity to publicPublic void OnCreate (Bundle savedinstancestate)
4. Use annotations to complete UI bindings and event bindings before the OnCreate methodno need to use Findviewbyid and Setclicklistener@ViewInject (id = r.id.bt, click = "Btclick") button BT;@ViewInject (id = r.id.tv) TextView TV;
5. Click the method name of the event to be the same as the method name in the annotationThe return value of the event must be voidthe permission must be publicPublic void Btclick (View v) {tv.settext ("Afinal open source framework in \nfinalactivity use! "); }
Layout File
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools " android:layout_width=" match_parent " android:layout_height=" Match_parent " android:orientation= "vertical" tools:context= ". Mainactivity "> <button android:id=" @+id/bt " android:layout_width=" Wrap_content " android: layout_height= "Wrap_content" android:layout_gravity= "center" android:text= "button"/> < TextView android:id= "@+id/tv" android:layout_width= "wrap_content" android:layout_height= "Wrap_ Content " android:textsize=" 25SP "/></linearlayout>
Mainactivity.java
Package Com.example.openproject01afinalactivity;import Net.tsz.afinal.finalactivity;import Net.tsz.afinal.annotation.view.viewinject;import Android.os.bundle;import Android.view.view;import Android.widget.button;import Android.widget.textview;public class Mainactivity extends finalactivity{@ViewInject (ID = r.id.bt, click = "Btclick") button BT, @ViewInject (id = r.id.tv) TextView tv;public void OnCreate (Bundle savedinstancesta TE) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main);} public void Btclick (View v) {tv.settext ("Afinal Open source frame \nfinalactivity use! ");}}
results after the execution
Afinal use of finalactivity in the open source framework