AndroidAnnotations如何后的onCreate添加的init code [英] AndroidAnnotations how to add init code after onCreate

查看:150
本文介绍了AndroidAnnotations如何后的onCreate添加的init code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我定义为一个活动:

If I have an activity defined as:

@EActivity(R.layout.activity_login)
public class LoginActivity extends Activity

这将创建onCreate()方法对我来说,但我有额外的初始化code,我想onCreate方法去后,我应该怎么做呢?我可以创建自己的onCreate方法和使用空@EActivity,但有一个更好的办法?

This will create the onCreate() method for me, but I have extra init code that I want to go after the onCreate method, how should I do this? I could create my own onCreate method and use an empty @EActivity, but is there a better way?

推荐答案

使用的<一个href=\"http://www.jarvana.com/jarvana/view/com/google$c$c/androidannotations/androidannotations/2.2/androidannotations-2.2-javadoc.jar!/com/google$c$c/androidannotations/annotations/AfterViews.html\">@AfterViews注解来定义自己的初始化code:

Use the @AfterViews annotation to define your own initialization code:

@AfterViews
protected void init() {
    // your custom code
}

这还建议在 @EActivity javadoc.

这篇关于AndroidAnnotations如何后的onCreate添加的init code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆