I have a MainActivity
with an fragment view.
In the MainActivity
, I load this layout:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.MainLayout);
}
In the MainLayout, is an Float Action Button with the id "fab"
In my fragment view class, I load the fragment view layout like this:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
FragementView = inflater.inflate(R.layout.FragmentViewLayout, container, false);
FloatingActionButton fab = (FloatingActionButton) FragementView .findViewById(R.id.fab);
return FragementView;
}
Now I would like to get in the fragment view class, the fab (find by id) but this will be a null object.
Where is my mistake?