Android中的AndroidAnnotations

来源:互联网 发布:网络接口都有哪些 编辑:程序博客网 时间:2024/03/28 23:24

1、简介:是一个利用注解方式来简化代码结构,提高开发效率的开源框架,类似开源框架还有:roboguice 、butterknife 、dagger 等,该代码是一个第三方框架,通过注释来开发应用,使用Android Annotations能够大大减少代码量。

2、一些常用注释的使用方法:
@AfterInject 定义的方法在类的构造方法执行后执行
@AfterTextChange定义的方法在TextView及其子类的Text属性改变后执行
@AfterViews 定义的方法在setContentView后执行
@Background 定义的方法在后台线程执行
@BeforeTextChange 定义的方法在TextView及其子类的Text属性改变前执行
@Click 定义点击监听器
@EActivity 在Activity中启用Annotations
@EProvider 在 ContentProvider中启用Annotations
@EReceive 在BroadcastReceiver中启用Annotations
@EService 在Service中启用Annotations
@EView 在自定义的View的子类中启用Annotations
@Fullscreen 全屏
@NoTitle 无标题栏

3、eclipse的配置:http://jingyan.baidu.com/article/5552ef47c25fea518ffbc9e9.html

4、AvailableAnnotations


Enhanced components


@EActivity
@EApplication
@EBean
@EFragment
@EProvider
@EReceiver
@EIntentService
@EService
@EView
@EViewGroup
Injection


@AfterExtras
@AfterInject
@AfterViews
@App
@Bean
@Extra
@FragmentArg
@FragmentById
@FragmentByTag
@FromHtml
@HttpsClient
@NonConfigurationInstance
@RootContext
@SystemService
@ViewById
@ViewsById
Event binding


@TextChange
@AfterTextChange
@BeforeTextChange
@EditorAction
@FocusChange
@CheckedChange
@Touch
@Click
@LongClick
@ItemClick
@ItemLongClick
@ItemSelect
@OptionsItem
@SeekBarProgressChange
@SeekBarTouchStart
@SeekBarTouchStop
Threading


@Background
@UiThread
@SupposeBackground
@SupposeUiThread
Misc


@InstanceState
@WindowFeature
@Fullscreen
@NoTitle
@CustomTitle
@OptionsMenu
@OptionsMenuItem
@OrmLiteDao
@RoboGuice
@Trace
@Transactional
@OnActivityResult
@OnActivityResult.Extra
@HierarchyViewerSupport
@ServiceAction
@Receiver
@ReceiverAction
@ReceiverAction.Extra
@IgnoredWhenDetached
@WakeLock
Resource injection


@StringRes
@AnimationRes
@ColorRes
@DimensionPixelOffsetRes
@DimensionPixelSizeRes
@DimensionRes
@BooleanRes
@ColorStateListRes
@DrawableRes
@IntArrayRes
@IntegerRes
@LayoutRes
@MovieRes
@StringArrayRes
@TextArrayRes
@TextRes
@HtmlRes
Rest API


@Rest
@RestService
@Get
@Post
@Put
@Delete
@Options
@Head
@Accept
@RequiresHeader
@RequiresCookie
@RequiresCookieInUrl
@RequiresAuthentication
@SetsCookie
@RequiresCookieInUrl
Typesafe SharedPreferences


@DefaultBoolean
@DefaultFloat
@DefaultInt
@DefaultLong
@DefaultString
@DefaultStringSet
@DefaultRes
@Pref
@SharedPref 介绍到此,用到了再详细看他的文档。

0 0