问题
I am making to show progressbar on postexecute and to be not visible in postExecute, and it works, but makes the app to work very slow, what is the reason is there any simple way to make it work normal(not slowly)? This is my code:
bar = (ProgressBar) this.findViewById(R.id.progressBar);
getInfo extends AsyncTask<void, void, void>{
protected void onPreExecute() {
bar.setVisibility(View.VISIBLE);
}
protected void doInBackground(String... params)
do smth}
protected void onPostExecute(Boolean results) {
bar.setVisibility(View.GONE);
}
}
回答1:
Are you using a custom progress bar and are you showing the progress bar at the initial screen of your application?
If you are using a custom progress bar then it might take some time to load during the initial startup of your app. I had a similar issue and the issue was due to the android:type="sweep" in the custom progress bar. EG: below
<shape>
<gradient
android:startColor="#000001"
android:centerColor="#ffffff"
android:centerY="0.5"
android:type="sweep"/>
</shape>
Not sure why the type="sweep" could cause the issue but, after removing it, the application seemed to start up pretty quick
来源:https://stackoverflow.com/questions/21160361/android-progressbar-makes-app-to-work-slower