how to access UI elements in parent activity from fragment
You can use:
((ParentActivity)getActivity()).UI_COMPONENT_NAME
to access the ui component of the parent activity.
UI_COMPONENT_NAME is the name of the component as initialised in the ParentActivity.
Since you want the Activity's views, you're going to want to do this:
ProgressBar progressBar = (ProgressBar) getActivity().findViewById(R.id.ctrlActivityIndicator);
You call getActivity()
to get the Activity instance then you use findViewById()
as normal (provided that R.id.ctrlActivityIndicator
is part of the Activity layout, you won't get NPEs).
This didn't work for me unitl i cast the result of getActivity to the parent activity. See link below: Call parent's activity from a fragment