gpt4 book ai didi

android - @InjectView 字段何时注入(inject)?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:28:07 26 4
gpt4 key购买 nike

Activity 中用 @InjectView@InjectResource 注释的字段究竟何时被注入(inject)?

最佳答案

根据 A Simple Example在 Roboguice 的网站上,成员在 ActivityonCreate() 方法调用 super.onCreate() 时填充:

class RoboWay extends RoboActivity { 
@InjectView(R.id.name) TextView name;
@InjectView(R.id.thumbnail) ImageView thumbnail;
@InjectResource(R.drawable.icon) Drawable icon;
@InjectResource(R.string.app_name) String myName;
@Inject LocationManager loc;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
name.setText( "Hello, " + myName );
}
}

关于android - @InjectView 字段何时注入(inject)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10018994/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com