Reputation: 12801
I am having some issuses while creating an intent to navigate to a different activity in my android app. When I create the intent function, it gives me an error saying
The constructor Intent(new View.OnClickListener(){}, Class<MapItmeizedOverlay>) is undefined
Here's the SelectOptions.java which has the startActivity intent
btnLocation.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent2 = new Intent(this, MapItmeizedOverlay.class);
startActivity(intent2);
}
});
Upvotes: 2
Views: 1831
Reputation: 132972
Please write below code
Intent intent2 = new Intent(Current_Activity.this, MapItmeizedOverlay.class);
startActivity(intent2);
instead of
Intent intent2 = new Intent(this, MapItmeizedOverlay.class);
startActivity(intent2);
for Starting new Activity on any View click use Current Activity Context or Application Context instead of View Context because Intent constructor take Current Context or application context as first parameter
Upvotes: 6