android Activity Group
Today i met with the serious problem. Actually i have 5 activities in my activity group.
from 1st activity i go to 2nd and from 开发者_Go百科2nd i go to 3rd and so on.... and on the 5th screen when i press back key i came to 4th and so on....
When i again go to the same process it displays me the previous displayed data as well on the screen. m not able to find the sollution for the same.
i need that every time i follow the process it will show me the new data not with the previous one data.
pls help me.
i cant paste the whole code. its 5 activities.
I don't think you mean "activity group," which is something else entirely. I assume you're talking about the task stack. What you probably want to do is override the onRestart
method on your activity, setting it to call whatever method it is that you use to refresh your view's underlying data. You may want to do that in conjunction with a member variable "dirty" boolean flag you set on your activity before you start another one so that it only triggers if you're coming back from another activity (and not when the user switches to another app and back to yours).
You can override back button of Android .
In that method you can clear all views from stack and set first view on screen. Below is Code from my app this you can use as per your requirement.
@Override
public void onBackPressed() {
super.onBackPressed();
Tab2GroupActivity.group.back();
}
In Tab2GroupActivity class
public void back() {
if (history.size() > 0) {
history.remove(history.size() - 1);
setContentView(history.get(history.size() - 1));
} else {
finish();
}
}
Here history is my list which contains all opened views in it.
this solved my issue.
精彩评论