Не следует устанавливать видимость progressBar после начала нового действия. Самая простая вещь, которую вы можете сделать, это использовать переменную flag для хранения состояния вашего индикатора выполнения.
startActivity(intent);
progressBar.setVisibility(View.GONE); // should be avoided
РЕШЕНИЕ:
private ProgressBar progressBar;
String progressBarState = "empty"
String PROGRESS_BAR_LOADING = "LOADING"
String PROGRESS_BAR_LOADED = "LOADED"
mhelp = (LinearLayout) root.findViewById(R.id.lythelp);
mhelp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(PROGRESS_BAR_LOADING == "LOADING")
progressBar.setVisibility(View.VISIBLE);
Intent intent = new Intent(getActivity(), Help.class);
startActivity(intent);
}
Внутри HelpActivity (или любой другой деятельности, которую вы хотите запустить):
override onCreate(): void {
/*
* You will need a progress bar on this activity's view
* as well if you are transitioning between activities and
* want to maintain the progress.
*/
progressBar.setVisibility(View.GONE);
/*
* You can pass the progress between the activities by
* passing the completion rate through the bundle that is
* sent through the activities.
* You can also add a key value pair for the progress bar's
* current state in that bundle and check for that state in the
* onCreate.
*/
}