It should be easy, right? So - this is how I defined ViewSwitcherin XML (Id and layouts omitted for brevity)
<ViewSwitcher android:layout_height="wrap_content" android:layout_width="fill_parent" >
<LinearLayout android:id="@+id/header1">
</LinearLayout>
<include android:id="@+id/header2" />
</ViewSwitcher>
Then somewhere in my Java code I have this code
ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.profileSwitcher);
switcher.bringToFront();
He just doesn't switch. I am developing for API v. 3 (1.5+), and, to my surprise, there are very few links to ViewSwitcher. Did I miss something obvious here?
PS I just discovered by brute force that this works:
switcher.setDisplayedChild(1);
However - why not luck with bringToFront()?
source
share