Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialomarshehab
477 PointsPlease i need help !
public abstract class main_Activity extends AppCompatActivity {
Button signinButton, signupButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
signinButton = (Button) findViewById(R.id.signinButton);
signupButton = (Button) findViewById(R.id.signupButton);
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.signinButton:
startActivity(new Intent(this, SignIn_Activity.class));
break;
}
}
};
signupButton.setOnClickListener(listener);
signinButton.setOnClickListener(listener);
}
when i hover over "startActivity(new Intent(this, SignIn_Activity.class)); it gives me the error ( Cannot resolve constructor 'Intent(anonymous android.view.View.OnClickListener, java.lang.Class<database.application.SignIn_Activity>)' )
by the way there is a class i created called "SignIn_Activity" please help.
3 Answers
Jeremy Faith
Courses Plus Student 56,696 PointsIn your startActivity, try changing this to main_Activity.this.
Kevin Faust
15,353 PointsOr you could create a new method that launches the intent. Because right now you are calling this which is referring to the onclick listener
omarshehab
477 PointsThank you all for your help.