简体   繁体   English

如何在Android的启动画面中使用多个图像

[英]How to use multiple images in splash screen in android

Hello i am trying to create splash screen in android with one image but i want to display multiple images at a time in splash screen when app is launch. 您好,我正在尝试使用一个图像在android中创建启动屏幕,但是我想在启动应用时在启动屏幕中一次显示多个图像。 but it only displays one image please any solution for this please help me. 但它仅显示一个图像,请为此提供任何解决方案。 Here is my code. 这是我的代码。

public class MainActivity extends Activity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


new Thread(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub

                for(int i=0;i<5;i++)
                {
                    progress +=50;
                    h.post(new Runnable() {

                        @Override
                        public void run() {
                            // TODO Auto-generated method stub
                            pgr.setProgress(progress);
                            if(progress==pgr.getMax())
                            {
                                //pgr.setVisibility(4);
                                Intent in= new Intent(getApplicationContext(),Home.class);
                                startActivity(in);
                            }

                        }
                    });
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        // TODO: handle exception
                    }

                    }
                }


        }).start();
}
}

The simplest solution would be the use of CountDown timer, like, 最简单的解决方案是使用CountDown计时器,例如

below code would change activity after 10 sec and also change image after every 1 sec (change it according to your login). 下面的代码将在10秒后更改活动,并且每1秒更改一次图片(根据您的登录信息进行更改)。 int variable i to keep track of image changing number. int变量i跟踪图像更改编号。

int i = 0;

new CountDownTimer(10000, 1000) {

public void onTick(long millisUntilFinished) {
    i++;
    if(i == 1){
        imageview.setImageResource(R.drawable.image1);
    }
    else if(i == 2){
        imageview.setImageResource(R.drawable.image2);
    }
    else if(i == 3){
        imageview.setImageResource(R.drawable.image3);
    }
    //and so on..........................
}

public void onFinish() {
    //finish your splash screen activity
    SplashActivity.this.finish();
}

}.start();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM