Reputation: 2848
I'm trying to switch my fragments from classic implementation to AndroidAnnotations. When I use @EFragment(R.layout.my_fragment) I get a blank view.
@EFragment(R.layout.my_fragment)
public class MyFragment extends Fragment {
}
If I go like this it's ok :
public class MyFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.my_fragment, container, false);
return view;
}
}
What am I missing? The documentation says to add an underscore when I instanciate the fragment like :
MyFragment fragment = new MyFragment_();
instead of :
MyFragment fragment = new MyFragment();
But as I expected this is just giving a compilation error.
Upvotes: 3
Views: 4086
Reputation: 2848
I found the problem which was very simple :
After adding AndroidAnnotations to my fragment, I simply forgot to update the import of it in my Activty. It needed to change from:
import com.project.ui.fragment.MyFragment;
to:
import com.project.ui.fragment.MyFragment_;
After that the following :
MyFragment fragment = new MyFragment_();
works better, evidently.
Upvotes: 4