So I have these Codes here, It runs without crashing. However When I pass \"this\" into the gridadapter the mContext is null. I tried to pass getApplicationContext() through but
The root of your problem is that you are trying to initialize a member variable inline with
int[] champImage = getImage();
This executes before the constructor which sets mContext
to a valid value. However, the fact that mContext
is null
inside the call for getImage()
should be irrelevant because you never actually use mContext
in that method.
The overall issue is that you need to be careful about the order of execution.