Access Fragment View from Activity's onCreate Access Fragment View from Activity's onCreate android android

Access Fragment View from Activity's onCreate


Update your views in onCreateView().

@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,     Bundle savedInstanceState) {    View view = inflater.inflate(R.layout.event_log, container, false);    TextView tv = (TextView) view.findViewById(R.id.text);    tv.setText("hello world");    return view;}

Or if your changes depend on Activity your Fragment is attached to, use onActivityCreated().

@Overridepublic void onActivityCreated (Bundle savedInstanceState) {    super.onActivityCreated(savedInstanceState);    TextView tv = (TextView) getView().findViewById(R.id.text);    tv.setText(getActivity.getSomeText());}