androidstudio
androidstudio

Reputation: 11

Why does Android Studio keep asking for a "Expression Expected"?

Here is my code:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    btnSighin = (Button) findViewById(R.id.btnSignIn);
    btnSignUp = (Button) findViewById(R.id.btnSignUp);

    btnSignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent j = new Intent(MainActivity.this, SignUp.class);
            startActivity(SignUp);
        }
    });

    btnSighin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick (View view) {
            Intent k = new Intent(MainActivity.this, SignIn.class);
            startActivity(SignIn);

        }
    });
}

I am working on an app that allows customers to book appointments and in order to do so, they need to sign up or sign in. I have activities made for both of them and I can't run it without getting the "Expression Expected" and I'm new to Android Studio and have no idea what to do. Any help?

Upvotes: 1

Views: 1530

Answers (2)

Arun Gopinathan
Arun Gopinathan

Reputation: 388

You have to pass the intent object to the start activity method not the signup or signin class So it should be startActivity(i) and startActivity(j)

Upvotes: 0

You are missing some information. Anyway, i see that you have mistakes in lines

startActivity(SignUp);

and

startActivity(SignIn);

The correct way should be startActivity(j) and startActivity(k) respectively

Upvotes: 4

Related Questions