There is 2 main problems with your code sample:
1) You told the injector how to create an ITweet
instance, not a List<ITweet>
.
Also, how do you expect RoboGuice to know what tweets you want in that list ?
You could implement a Provider
to do something like that, but that seems a bit too much IMO. A simpler way would be to add a setter to your adapter, and set the data to your adapter after it has been instantiated by RoboGuice.
2) You cannot use @InjectView
in a ArrayAdapter
If you look at the code of RoboActivity
, you'll see this code in the onContentChanged()
handler:
@Override
public void onContentChanged() {
super.onContentChanged();
RoboGuice.getInjector(this).injectViewMembers(this);
eventManager.fire(new OnContentChangedEvent());
}
The injectViewMembers()
method is the one doing the magic behind @InjectView
.
Sadly this method only accept an Activity
or a Fragment
.
You might have a look at Butterknife (by Jake Wharton), which is leaner than RoboGuice for views injection.