سؤال

I have some strange effects in my Android App.

I use a TabHoster with TabGroupActivities for each Tab. Works pretty good except the behaviour of the Back Button.

An Activity is launched and responds to the Back button. Then I start a Child Activity with a ViewSwitcher. When i hit the Back Button on View A Activity is dismissed as Expected. But it gets through the onBackPressed() of my Activity.

When i hit the Back Button on View B (detailView==true) the Method is not even Called. Instead of that the onBackPressed() of the TabGroupActivity is Called and I am not able to switch back to the first View.

@Override
public void onBackPressed() {
    if (detailView == true){
        vf.showPrevious();
        detailView = false;
    }
    else {
        super.onBackPressed();
    }
return;
}

Can Anybody explain this and/or tell me how to switch between Views in an Activity in an ActivityGroup?

هل كانت مفيدة؟

المحلول

Few Days later i came to the Conclusion that it is FOR MY CASE the easiest solution to throw away the ViewSwitching stuff and transfer them to seperate Activities.

Sebastian Olsson is surely right with the fragments but it would be more effort for my specific App to rebuild everything to fragments.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top