如何使用进度条实现启动画面? - android

kum*_*ded 4 java android timer splash-screen progress-bar

我在启动时有一个启动画面.用以下编码

public class Splash extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    Thread logoTimer = new Thread(){
        public void run(){
            try{
                int logoTimer = 0;
                while (logoTimer<5000){
                    sleep(100);
                    logoTimer=logoTimer+100;
                     }
                startActivity(new Intent("com.package.MAIN"));
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
            finally{
                finish();
            }
        }
    };
    logoTimer.start();
}}
Run Code Online (Sandbox Code Playgroud)

现在我只想在屏幕底部的上面的启动活动中添加一个水平进度条.所以当启动屏幕同时出现时,应该加载进度条,当它完成时,应该出现下一个活动.

在进度条上搜索了几个例子但是没能做我想要的.进度条有很多带有对话框的例子.但在这里我不想要任何对话框.我只需要在启动画面上使用普通的水平进度条.

有人可以用必要的编码和东西来帮助我吗?请!:)

Blu*_*ell 7

在这里,您编写了一个教程,如何使用进度条创建SplashScreen:

http://blog.blundellapps.com/tut-splashscreen-with-progress-bar/

基本上不是你的线程它启动ASyncTask,你将progressSpinner的引用传递给ASyncTask,这将在线程下载资源(或任何你想做的事情)时更新它