Skip to content Skip to sidebar Skip to footer

Can't Start Activity When Pressing An Element On Gridview

i want to start an Activity when any Image from the GridView is clicked. I maked this but i have an error on getApplicationContext() : The method getApplicationContext() is undefin

Solution 1:

The problem is because of poor reference to Context. Try this instead,

 Intent intent = newIntent(imageView.getRootView().getContext(), carburant.class);
                     startActivity(intent);

Solution 2:

You have a scope issue. View does not have a getApplicationContext() - you must access the parent activity's scope to get the app context.

Intent intent = newIntent(MyParentActivity.this.getApplicationContext(), carburant.class);

Post a Comment for "Can't Start Activity When Pressing An Element On Gridview"