Activity中的startActivities(android.content.Intent [])无法应用于(android.content.Intent)

时间:2016-11-20 15:05:59

标签: android android-intent android-activity

我尝试做一个简单的应用程序,因为Intent Not working,它显示了这个错误:

  Activity中的 startActivities(android.content.Intent [])无法应用于(android.content.Intent)

为什么?

见下面我的代码:

public class SplashActivity extends Activity implements Animation.AnimationListener {
        ImageView imageView;
        Button button;
        Animation animationbounce;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_splash);
                imageView = (ImageView)findViewById(R.id.face);
                button = (Button)findViewById(R.id.splash);
                animationbounce = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bounce);
                animationbounce.setAnimationListener(this);
                imageView.setVisibility(View.VISIBLE);
                imageView.startAnimation(animationbounce);
                animationbounce.setRepeatMode(Animation.REVERSE);

                button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                        imageView.setVisibility(View.VISIBLE);
                        imageView.startAnimation(animationbounce);
                }
                });

                Thread timerThread = new Thread() {

                public void run() {

                try {
                        sleep(1000);


                } catch (InterruptedException e) {
                        e.printStackTrace();
                } finally {

                    Intent intents = new Intent(SplashActivity.this, MainActivity.class);
                    SplashActivity.this.startActivities(intents);
                    // startActivities(intents);

                        }
                }
        };
        timerThread.start();
        }

@Override
public void onAnimationStart(Animation animation) {
    imageView.setVisibility(View.VISIBLE);
    imageView.startAnimation(animationbounce);
        }

@Override
public void onAnimationEnd(Animation animation) {
        if(animation==animationbounce)
        {
            imageView.setVisibility(View.VISIBLE);
            imageView.startAnimation(animationbounce);
        }

        }

@Override
public void onAnimationRepeat(Animation animation) {

    imageView.setVisibility(View.VISIBLE);
    imageView.startAnimation(animationbounce);
        }
        }

2 个答案:

答案 0 :(得分:4)

startActivities期望提供一组Intent(Intent [])。你试图在那里传递一个Intent。请改用startActivity(Intent)

答案 1 :(得分:0)

试一试这对我有用

Button = (ImageButton) findViewById(R.id.button); Button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startActivities(new Intent[]{new Intent(getApplicationContext(), NextActivity.class)});