Revolutionair Revolutionair -4 years ago 151
Android Question

Views don't get injected by AndroidAnnotations in DialogFragment

The @ViewById annotations are not working in my DialogFragment.

I use


I create the fragment by doing

.init(someObject, new ClickListener() {...})
.show(getFragmentManager(), "myDialog");

is my custom method which returns the
for chaining.

I didn't override
, nor did I override
, and I'm not using any of the
annotations of AndroidAnnotations.

I'm trying to use the injected views in my
method, but they are null.

Answer Source

Just as I finished typing the question I realized what was wrong. I was assuming views would be injected by the time build() returned so I could use them in the init() method, but they weren't. The fix was to annotate another method with the @AfterViews annotation and do the view related initialization there.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download