I have an activity “MyListActivity“. I have an adapter associated with it “MyGridAdapter“. It contains a grid of buttons (say 3). Each button has a “OnClickListner()”.
On click of the 1st button, I would have to take the same action. So, instead of creating similar another activity, I decide to RE-USE the same page. Meaning: I need to call “MyListActivity” but with some modified parameters- increased number of buttons etc…
I tried to use, “invalidate()” on button click. But it re-loads the same page without any changes.
How to call the same activity from a function in the adapter?
My work around for the problem: I created another “tempActivity“. in one of the function I am trying to start the previous activity.
code inside “MyGridAdapter“:
TempActivity temp=new TempActivity();
temp.setIntentObj(<parameters>);
inside “TempActivity”:
Intent intent=new Intent(this,ListActivity.class); //this gives a "NullPointerException"
startActivity(intent);
In the adapter class, we can start an activity using
context.startActivity(intent)I did not know that we can access “start Activity” from adapter… but now it’s working just fine!! Thanks a lot for your recommendation…