ProgressBar使应用程序运行速度变慢

ProgressBar使应用程序运行速度变慢

本文介绍了Android ProgressBar使应用程序运行速度变慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在postexecute上显示进度条,并且在postExecute中不可见,并且它可以工作,但是却使应用程序运行非常缓慢,这是为什么有任何简单的方法可以使其正常运行(不缓慢)? ?这是我的代码:

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);
    }
}

推荐答案

您是否正在使用自定义进度栏,并且是否在应用程序的初始屏幕上显示进度栏?

Are you using a custom progress bar and are you showing the progress bar at the initial screen of your application?

如果您使用的是自定义进度栏,则在应用程序的初次启动过程中可能会花费一些时间来加载.我遇到了类似的问题,该问题是由于自定义进度栏中的android:type ="sweep"引起的. EG:下方

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>

不确定为什么type ="sweep"可能导致此问题,但是在删除它之后,该应用程序似乎很快启动了

Not sure why the type="sweep" could cause the issue but, after removing it, the application seemed to start up pretty quick

这篇关于Android ProgressBar使应用程序运行速度变慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 19:43