@Tyhj
2016-11-07T14:30:08.000000Z
字数 2247
阅读 1304
实验班-翻译
AndroidAnnotations是一个Androidkai开发框架,它是一个Java注解框架,可以让Android代码变得jian简洁,用更少的代码实现功能。
原文标题:AvailableAnnotations
译文标题:AndroidAnnotations的使用
来源:https://github.com/androidannotations/androidannotations/wiki/AvailableAnnotations
1.
The @EActivity annotation indicates that an activity will be enhanced by AndroidAnnotations. Its value parameter must be a valid layout id, that will be used as the Content View for the activity.
You can leave the value parameter empty, which means that no content view will be set. You will probably want to set the content view yourself in the onCreate() method, before the binding is done.
该@EActivity注解表明一个活动将得到加强AndroidAnnotations。其值参数必须是一个有效的布局ID,将要用作内容视图的活性。
您可以将value参数为空,这意味着没有内容视图将被设置。你可能会想要设置的内容查看自己的onCreate()方法,结合之前完成。
2.
Annotate your methods to ensure they are called from a background thread with (optionally) restrictions by allowed serials. If it is not called from a supposed background thread, then IllegalStateException will be thrown (by default). The allowed IDs can be passed to the serial parameter, if nothing is passed, any ID is allowed.
If you want to override what happens when the method is not called on the supposed thread, pass an instance of BackgroundExecutor.WrongThreadListenerto BackgroundExecutor.setWrongThreadListener(). Its onBgExpected method will be invoked if the annotated method is called on the wrong thread, or its onWrongBgSerial will be invoked if the annotated method called on a background thread but with wrong IDs.
注释你的方法,以确保它们从后台线程调用(可选)通过允许连续的限制。如果不是从所谓后台线程调用,那么IllegalStateException将(默认)被抛出。允许IDs时,可以传递给serial的参数,如果没有通过,任何ID被允许的。
如果你想重写时,该方法不叫所谓线程上发生了什么,通过实例BackgroundExecutor.WrongThreadListener来BackgroundExecutor.setWrongThreadListener()。它onBgExpected如果标注的方法被称为错误的线程上的方法将被调用,或它onWrongBgSerial会调用如果调用在后台线程但错误的ID所注解的方法。
3.
Based on that specification, AndroidAnnotations builds a SharedPreferences Helper that has the same name plus an underscore. You can get an instance of the generated helper in any enhanced class with the @Pref annotation.
根据该规范,AndroidAnnotations建立一个SharedPreferences助手具有相同的名称加下划线。你可以与任何增强类获取生成的助手的实例@Pref诠释。
4.The annotation value should be one or several R.string.* fields that refers to Preference or subclasses of Preference. If not set, the method name will be used as the R.string.* field name.
注释值应该是一个或几个R.string。*,指的领域Preference或子类Preference。如果没有设置,方法名称将被用作R.string *字段名。
annotation 注释
fields 领域
target 目标
parameter 参数
subclass 子类
layout 布局
content 内容
bind 结合
indicates 表明