I have a class extending ParseQUeryAdapter so I can use the notifyDataSetChanged
feature. The adapter class is called mainAdapter
.
Here's my notifyDataSetCHanged method in the mainAdapter:
@Override
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
MainActivity mainActivity = new MainActivity();
mainActivity.getItems();
}
Here's my getItems() method in MainActivity:
public void getItems(){
if(adapter == null){
Toast.makeText(MainActivity.this, "null", Toast.LENGTH_SHORT).show();
}
}
The app crashes on loading. As you can see, I planted an if
so that I can see if adapter
was null. But it still crashes.
According to the debugger, it says in green after getting to the if
line, "adapter:null". However, I have this in onCreate():
adapter = new mainAdapter(this);
And I declared it:
mainAdapter adapter
Is there a method I can put in that will solve my issue? Although I am implementing the class, why is it still null? I clearly stated that adapter = new mainAdapter()