Let's say following is my fragment.
public class FieldsFragment extends Fragment {
LinearLayout linearLayout;
ScrollView scrollView;
ViewGroup rootView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = (ViewGroup) inflater.inflate(
R.layout.single_field_fragment ,null);
scrollView = (ScrollView) rootView.findViewById(R.id.single_field_scrollView);
return rootView;
}
public void setLinearLayout(LinearLayout linearLayout){
scrollView.removeAllViews();
scrollView.addView(linearLayout);
}
public LinearLayout getLinearLayout(){
return linearLayout;
}
}
What I want to do is ...
ArrayList<FieldsFragment> fragmentList = new ArrayList<FieldsFragment>();
fragment = new FieldsFragment();
fragment.setLinearLayout(lL);
fragmentList.add(fragment);
just want to parse my linear layouts to the fragment from other activity in order to use in FragmentStatePagerAdapter...
the problem is I can't setLinearLayout(myLayout1) without initiating the scrollView (findViewByID).
My work flow is so simple... (1) to pull linearLayout's from server.. (2) set them to each FieldsFragment and add them to ArrayList (3) and use that ArrayList to put FragmentStatePagerAdapter. The purpose is to slide all linearlayout got from server.