I have this problem where the fragment.getView() always returns null when called inside another activity despite the fact the the onCreateView method was overriden in side the fragment.
For example: In my activity:
frag = new NewBooksFrag();
In my fragment:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View view = null;
view = inflater.inflate(R.layout.new_book_frag, container,true);
return view;
}
but when i call
frag.getView()
it stills returns null. Any idea why is this happening? Because in the android documentation, it clearly states getView():
"Get the root view for the fragment's layout (the one returned by onCreateView(LayoutInflater, ViewGroup, Bundle)), if provided."
if this returns null, how can we reference to the view of the fragment?
Thanks in advance