Android App Development framework: Android Annotations Learning notes Summary

Source: Internet
Author: User
Tags hosting sites


Android App Development framework: Android Annotations

Android Annotations is an open-source framework for accelerating the development of Android applications, allowing you to focus on the implementation of functionality, simplifying code, and improving maintainability. In fact, there are many books in the open-source world of programming, but GitHub has many useful projects and open source code on social networking sites and code hosting sites, such as the Android app development Framework Android Annotations, So the improvement of English level is imperative ah, otherwise I can only wait until the translation team to guess my turn to chew a new knowledge, technology and application, so late others a lot of steps.

Characteristics:

• Dependency Injection: Inject views, extras, system services, resources, ...

• Simplified threading Model: Annotate your methods So, they execute on the UI thread or on a background thread.

Event Binding: Annotate methods to handle events in views, no more ugly anonymous listener classes!

REST clients: Create a client interface, Androidannotations generates the implementation.

androidannotations provide those good things and even more for less than 50kb, without any runtime perf impact!

code example:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21st

22

23

24

25

26

27

28

29

30

31

@EActivity (r.layout.translate)//sets content view to R.layout.translate

public class Translateactivity extends Activity {

@ViewById//Injects R.id.textinput

EditText TextInput;

@ViewById (R.id.mytextview)//injects R.id.mytextview

TextView result;

@AnimationRes//Injects Android. R.anim.fade_in

Animation FadeIn;

@Click//When R.id.dotranslate button is clicked

void Dotranslate () {

Translateinbackground (Textinput.gettext (). toString ());

}

@Background//Executed in a Background thread

void Translateinbackground (String texttotranslate) {

String Translatedtext = callgoogletranslate (texttotranslate);

Showresult (Translatedtext);

}

@UiThread//Executed in the UI thread

void Showresult (String translatedtext) {

Result.settext (Translatedtext);

Result.startanimation (FadeIn);

}

// [...]

}

Project home: http://www.open-open.com/lib/view/home/1367820981261

This project homepage can be found to download the jar package for Android annotations.

Then here is an example of how to use this android annotations jar package:

Note: One of the API's jar packages is placed under the original Libs folder, and the other jar package is placed under its own new Compilb-lib folder.

Note: anootation processing is found in Java complier.

If there is no probable reason you are using the Android SDK Adt-eclipse, which is dedicated to developing Android, you will need to download the relevant configuration.

Then choose Juno Installation, and then because the file is too many hard to find, enter the Eclipse Java development Tools you want to download in type filter text, then there may be different versions, naturally choose the latest version, or the following tick show the latest version, There will be only this tools out, then next continue to click on the know-how to download and install the network, and finally prompt to restart

Once restarted, the anootation processing can be found in the Java complier.

Then we then cut into the topic:

Select annotation processing, and then tick Enabel project specific settings selected. Then select the factory Path under annotation processing:

Also tick Enabel project specific settings, then click Add JARs, add the jar under Compile-lib under the folder, then apply, then OK. This will enable the use of this Android annotations open source jar package.

The following is a simple explanation of how and how to use the effect, you can compare with your original Android application development in normal circumstances, you know this Android annotations Open source project brings the benefits of how big.

Examples of using procedures:

1, first in the Manifest list file modified, is in Android:name= ". Mainactivity "followed by a" _ "to become Android:name=". Mainactivity_ ", do not ask why, this knowledge point of course is the Android annotations open source projects related to the use of knowledge.

2, and then back to Mainactivity.java, the following actions are implemented:

3, and then through their own mobile phone operation but success.




Android App Development framework: Android Annotations Learning notes Summary

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.