Briefly, the NullPointerException exception is thrown whenever you try to access a object that has not been instantiated, or better initialized, until the moment of its call.
First thing to note is that you are declaring two variables of type Spinner
, globally in your inner class and within onPreExecute()
. Declare only once so that the error does not occur. Here's how your method onPreExecute()
would look like:
@Override
protected void onPreExecute() {
super.onPreExecute();
spinner = (Spinner) findViewById(R.id.memo_confirmation_spinner );
spinner.setOnItemSelectedListener(this);
}
Second factor is that as you are saying that the error is in this line below:
spinner = (Spinner) findViewById( R.id.memo_confirmation_spinner );
Try to notice in your out class if you are not calling your JSONOAsyncTask
before setContentView()
. If so, just reverse doing this:
setContentView(R.layout.sua_activity);
new JSONOAsyncTask.execute();