Androidannotations using annotations to develop applications

Source: Internet
Author: User

androidAnnotations is a third-party framework that uses annotations to develop applications. Using androidannotations can greatly reduce the amount of code.

[Java]
Package com.example.androidannotations;
Import android.app.Activity;
Import Android.widget.TextView;

Import Com.googlecode.androidannotations.annotations.AfterViews;
Import com.googlecode.androidannotations.annotations.EActivity;
Import Com.googlecode.androidannotations.annotations.ViewById;

Eactivity annotations can be set to layout, equivalent to the Setconentview method
@EActivity (R.layout.activity_main)
public class Mainactivity extends Activity {
Viewbyid annotation function is the same as Findviewbyid, if the declared variable name is ID, you can omit the parameter, otherwise you should add the ID, such as Viewbyid (r.id.tv)
@ViewById
TextView TV;
The method defined by the Afterviews annotation is executed after the Setcontentview of the OnCreate method
@AfterViews
void Init ()
{
Tv.settext ("Asfsdf");
}
}

Package com.example.androidannotations;
Import android.app.Activity;
Import Android.widget.TextView;

Import Com.googlecode.androidannotations.annotations.AfterViews;
Import com.googlecode.androidannotations.annotations.EActivity;
Import Com.googlecode.androidannotations.annotations.ViewById;

Eactivity annotations can be set to layout, equivalent to the Setconentview method
@EActivity (R.layout.activity_main)
public class Mainactivity extends Activity {
Viewbyid annotation function is the same as Findviewbyid, if the declared variable name is ID, you can omit the parameter, otherwise you should add the ID, such as Viewbyid (r.id.tv)
@ViewById
TextView TV;
The method defined by the Afterviews annotation is executed after the Setcontentview of the OnCreate method
@AfterViews
void Init ()
{
Tv.settext ("Asfsdf");
}
}
How to use some common annotations:
@AfterInject defined methods are executed after the constructor method of the class is executed
@AfterTextChange defined method executes after the text property of the TextView and its subclasses is changed
@AfterViews defined methods are executed after Setcontentview
@Background defined methods are executed in the background thread
@BeforeTextChange defined methods are executed before the Text property of the TextView and its subclasses is changed
@Click Define Click Listeners
@EActivity enable annotations in activity
@EProvider enable annotations in ContentProvider
@EReceive enable annotations in Broadcastreceiver
@EService enable annotations in the service
@EView enable annotations in a child class of a custom view
@Fullscreen fullscreen
@NoTitle No title bar

Androidannotations using annotations to develop applications

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.