How do i call on a seperate activity within a method:
For example:
private void startApp() {
Patient_Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// I want this Button to go to an Detailed_ModeActivity
// This is how i Am doing it right now, but it comes out with an
// error
Intent b = new Intent(this, Detailed_ModeActivity.class);
startActivity(b);
}
});
}
Any Help would be appreciated.
The Button was declared in the onCreate method
The
thisrefers to anView.OnClickListenerobject which doesn’t havestartActivity()method and cannot be passed to anIntent. You need to callstartActivity()on a Context (e.g. an Activity). Let’s say your code is in theMainActivityclass. Like this: