簡単なはずですよね?だから - これが私がViewSwitcher
XMLで定義した方法です(簡潔にするためにIDとレイアウトは省略されています)
<ViewSwitcher android:layout_height="wrap_content" android:layout_width="fill_parent" >
<!-- First view, comes up OK -->
<LinearLayout android:id="@+id/header1">
<!-- some more controls: Progress bar, test view and the button -->
</LinearLayout>
<!-- second view. changing to the actual (not include) layout has no effect -->
<include android:id="@+id/header2" />
</ViewSwitcher>
次に、Javaコードのどこかにこのコードがあります
ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.profileSwitcher);
// more code that basically executes background search
// when call comes back - switch
switcher.bringToFront(); // does nothing
// switcher.bringChildToFront(findViewById(R.id.header2)); // no effect ether
切り替わらないだけです。私は API v. 3 (1.5+) 向けに開発していますが、驚いたことに、ViewSwitcher への参照はほとんどありません。ここで明らかな何かが欠けていますか?
PS私はこれがうまくいくことを力ずくで知りました:
switcher.setDisplayedChild(1);
それでも - なぜ運がないのbringToFront()
ですか?