I have an application with a TabActivity containing ActivityGroup. Each tabs works fine, but for one specific tab I want to go back to the first child activity when there's a click on it (whenever we are in a child activity of this tab or inside another tab).
I tried to start the activity that I want on the onResume of my ActivityGroup, it works when I'm on another tab, but not when I'm on this tab, wi开发者_运维知识库th a child activity.
Do I have to use another intent flag than FLAG_ACTIVITY_CLEAR_TOP for this tab ? Does anyone have a clue ?
Thanks.
Usualy with ActivityGroup you have some kind of history.
Let's say your history is:
ArrayList<View> history;
Of course history needs to be initialized and have some Views in it which can be retrieved with:
getLocalActivityManager().startActivity(clazz.getName(), new Intent(this, clazz)).getDecorView();
where clazz is the class of your child Activity. So on click in current ActivityGroup define a method like:
public void backToFirst() {
int size = history.size();
while (size > 1) {
history.remove(size - 1);
size = history.size();
}
setContentView(history.get(0));
}
Hope I understood you correctly and this is the answer you are looking for.
精彩评论