We are creating an app with two main views: sView and sViewSettings. If the Android Back button is pressed we want an if statment to check if the current view is set to sView settings, if it is then call the sView.
Already have a listener setup for the back button just need it to call the if statement to check the current view.
Have already tried
if (this.findViewById(android.R.id.content) == sViewSettings)
Any ideas on this?
Thank you for Reading,
Travis
The view with id
android.R.id.contentis aFrameLayoutholding your content view. Try this:However, I suggest a slightly different approach: use a
ViewSwitcher(or any kind ofViewAnimator) to flip between the two main views and keep track in your code of which one is on display.EDIT: If you want to keep your layouts loaded separately, you can assign an id (the same one) to the root view of each layout and then retrieve the content view directly using
findViewById.