When are @InjectView fields injected?

Go To StackoverFlow.com

5

Exactly when are an Activity's fields that are annotated with @InjectView or @InjectResource injected?

2012-04-04 20:46
by Jeff Axelrod


7

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 ); 
    } 
}
2012-04-04 20:49
by Jeff Axelrod
Ads