Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7419325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:02:59+00:00 2026-05-29T08:02:59+00:00

We are creating an app with two main views: sView and sViewSettings. If the

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:03:00+00:00Added an answer on May 29, 2026 at 8:03 am

    The view with id android.R.id.content is a FrameLayout holding your content view. Try this:

    ViewGroup contentFrame = (ViewGroup) findViewById(android.R.id.content);
    if (contentFrame.getChild(0) == sViewSettings) { ... }
    

    However, I suggest a slightly different approach: use a ViewSwitcher (or any kind of ViewAnimator) 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating android app that has table layout for the main activity, and that
I have an app where I am creating two subviews of the main window,
If I'm creating a universal iPhone/iPad app, I have two XIBs. One main XIB
I'm creating a SMS fording app. I currently got two classes; a main Activity
I'm creating an iPad app, and I have two classes: NWRootViewController : UITableViewController and
We're creating a new consumer/public-facing ASP.Net web app. There are two concerns: --Use cookie
I am creating console app, involving lots of services. I want to display a
I'm creating an app using a UITabBarController as the main form of navigation, having
I am creating an app (not a game), and I want to make it
I have two app domains, one parent creating the child domain. In the child

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.