问题描述:

I am using the Window feature progress bar to show the loading progress of two of the 6 fragments that I have. They work fine, showing from 0 to 100% and automatically hiding when reaching 100%.

When I change to one of the fragments that doesn't use it, the progress bar stills hidden but, If I rotate the device, the progress bar reappears full and never hides until I load one of the fragments that use it.

I tried putting a value of 50% during the onCreate to see if the bar reappears with a value of 50% but it doesn't, stills 100%.

I tried to change the visibility of the progress bar in each fragment but even with setProgressBarVisibility(false); in the fragment.onCreate stills showing up.

I placed breakpoints in all the functions that set the progress and no one is called during the orientation change.

Activity onCreate:

requestWindowFeature(Window.FEATURE_PROGRESS);

setContentView(R.layout.activity_main);

setProgressBarVisibility(true);

Function to change progress:

public void setProgress(final int progress) {

if(progress==100)

((MainActivity)activity).getSimulator().setBrowserLoaded(true);

activity.runOnUiThread( new Runnable() {

public void run() {

activity.setProgress(progress * 100);

}

});

}

网友答案:

Try using:

android:configChanges="orientation"

in your app manifest for the particular activity.

相关阅读:
Top