glenviewjeff
unread,Jun 26, 2011, 9:48:11 PM6/26/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to robo...@googlegroups.com
I've got a custom ArrayAdapter that I want to inject, but if I inject the activity into the custom ArrayAdapter, I get the following error on the super(context, textViewResourceId, objects); call:
Cannot refer to an instance field activity while explicitly invoking a constructor.
This error is because Java thinks that the fields can't possibly be initialized prior to the call to super. Of course, I'm injecting the context. Does anyone know how to get around this problem? I'd very much like to avoid making the injected members static.
public class MyListAdapter extends ArrayAdapter<MyThing> {
@Inject
private MyListAdapterData myListAdapterData;
@Inject
private Activity activity;
public MyListAdapter(int textViewResourceId) {
super(activity, textViewResourceId, myListAdapterData.getSubCategories());
...