Exactly when are an Activity
's fields that are annotated with @InjectView
or @InjectResource
injected?
According to A Simple Example on Roboguice's website, the members are populated by the time super.onCreate()
has been called from the Activity
's onCreate()
method:
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 );
}
}