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)