启动画面取决于点击继续前进

时间:2015-12-13 09:26:59

标签: java android alertdialog splash-screen

目前,我的启动画面直接链接到我的mainActivity。旋转持续时间结束时,闪屏结束。 android:duration="8000"

然后我在那里有警告对话框。

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);


        final ImageView iv = (ImageView) findViewById(R.id.imageView);
        final Animation an = AnimationUtils.loadAnimation(getBaseContext(), R.animator.rotate);
        final Animation an2 = AnimationUtils.loadAnimation(getBaseContext(), R.anim.abc_fade_out);

        iv.startAnimation(an);
        an.setAnimationListener(new Animation.AnimationListener() {


            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                iv.startAnimation(an2);
                finish();
                Intent i = new Intent(getBaseContext(), MainActivity.class);
                startActivity(i);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        new AlertDialog.Builder(this).setTitle("Promo Code").setMessage("Type in 'VC2001' for a 10% discount. Only applicable for VC-20U").setNeutralButton("Close", null).show();

    }
`

那么,点击关闭后有什么方法可以结束启动画面吗?

这可能真的听起来很愚蠢,因为我在android

中真的很新

1 个答案:

答案 0 :(得分:1)

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(yoursplashscreen.this);

       dialogBuilder.setTitle("Promo Code");
dialogBuilder.setMessage("Type in 'VC2001' for a 10% discount. Only applicable for VC-20U");


        dialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                // finish your splash screen here and set intent to your new activity
                finish();
                Intent i = new Intent(getBaseContext(), MainActivity.class);
                startActivity(i);
            }
        });
        AlertDialog alertDialog = dialogBuilder.create();
        alertDialog.show();