Search code examples
androidviewflipper

Android overriding onBackPress unexpected behaviour


Yet another problem whilst trying to create the UI for an app.

I've got a Viewflipper in a tab which slides from View 1 to View 2 to View 3. I've overridden the onBackPress method to navigate back to a previous view if I am not on View 1.

It works fine when on View 2, pressing back goes to View 1. But when on View 3, pressing back ends the Tab activity and takes me back to the sign in activity.

Here's a video in case my description was hard to understand: http://www.youtube.com/watch?v=2nKhgpq3rQA

Has anyone come across anything similar? Why does the onBackPress get ignored in my Tab Activity when View 3 is displayed? I've debugged and put a breakpoint on the onBackPressed method in my Tab Activity, the breakpoint is hit in all cases except for when View 3 is the shown view. Werid.

Thanks for your time.

Update: I've discovered that if I add another ListView as the View 3 it works, but if I add a TextView as View 3 it doesn't behave as expected, crazy.


Solution

  • I solved this, there was some weird behaviour because I was adding the first view in my view flipper to the tab content, rather than adding the viewflipper itself.