Afinal use of finalactivity in the open source framework

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.