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 3952486
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:51:23+00:00 2026-05-20T01:51:23+00:00

Ans: Use viewFlipper.getCurrentView().getId() Hi, I’m stuck in a position where I have to execute

  • 0

Ans: Use viewFlipper.getCurrentView().getId()

Hi,
I’m stuck in a position where I have to execute a set of statements based on the screen that is being displayed (Have to use IF condition). The layout folder contains only one screen (i.e., main.xml). But inside the main.xml there are three absolute layouts (01,02 & 03). I’m using flipper to swipe through these screens.

Earlier when I used to switch between two screens (main.xml and main2.xml), I had no problem. I was using two buttons to switch between the screens and I used a flag inside each button and used the same flag in my IF condition to execute the code. Now that I’ve implemented flipper, I’m unable to use flag. So I thought of using the LAYOUT ID in the IF condition. But I need to know how to check for the layout id in java coding. Can somebody help me out?

For Ex:

if(findViewById(R.id.AbsoluteLayout01)==true)
{
execute
}
else if(findViewById(R.id.AbsoluteLayout02)==true)
{
execute #2
}

(The above code throws the “Incompatible operand types View and boolean” error)

So I tried

if(findViewById()==v1) //v1 is the object for AbsoluteLayout01
{
execute
}
else if(findViewById()==v2) //v2 is the object for AbsoluteLayout02
{
execute #2
}

(The above code throws the “The method findViewById(int) in the type Activity is not applicable for the arguments ()” error)

  • 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-20T01:51:24+00:00Added an answer on May 20, 2026 at 1:51 am

    Simplest way, you can just call ViewFlipper.getDisplayedChild() and just compare based on the index (0, 1, 2). If it’s absolutely necessary to compare by id, you can also do:

    ViewFlipper vf = //whatever assignment
    switch(vf.getCurrentView().getId()) {
        case R.id.AbsoluteLayout1:
            //do work
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that I use BoneCP for connection pooling and when I
I have this font that I want to use it. I uploaded it to
I have a application which use two layouts in portrait ans landscape. To load
EDIT: solved. ans var needed to be set to 0 in every iteration.That was
If I have an anonymous type created by LINQ var ans = from r
I have VS 2010 , when i go to tools/Extension Manager ans start getting
I start learning some java concurrency concept ans put in use. But one of
I have wrote a basic web service using .net which I intend to use
I use 2 WebForms ans I want use one webform and from this I
iam developing one application.In that i use the label and textfield in same line.Every

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.