I have the following problem in code I create fragment and that is OK.
My problem is when I try to set him and parameter.
Here is my code.
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
0, ViewGroup.LayoutParams.WRAP_CONTENT);
params.weight = 1.0f;
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
FragmentImageList myFragment = new FragmentImageList();
fragmentTransaction.add(631, myFragment, "fragmentTag");
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
myFragment.getView().setLayoutParams(params);
And then in the console I have the following error.
Attempt to invoke virtual method 'void android.view.View.setLayoutParams(android.view.ViewGroup$LayoutParams)' on a null object reference
In which makes sense because view of Fragment is not yet been created. But how to do it to set "Params" of created Fragment.