SherlockFragmentActivity 内に 4 つの SherlockFragment を含むビューページャー (アクションバー sherlock を使用) があります。
各タブには独自の backStack があります (各 SherlockFragment に複数のフラグメントをスタックできます)
私がやろうとしているのは、リスト内のアイテムを選択したときに、ViewStub (プレーヤー) を表示したいということです。
私の問題は、ViewPager が自分自身を修正しないことです。プレーヤーは表示されますが、viewpager の背後にあります。
メインの SherlockFragmentActivityは次のとおりです。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/ActivityDark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
tools:context=".ActivityMain" >
<ViewStub
android:id="@+id/main_stubplayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:inflatedId="@+id/fragment_allzic_player"
android:layout="@layout/view_player" />
<android.support.v4.view.ViewPager
android:id="@+id/main_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/main_stubplayer" >
</android.support.v4.view.ViewPager>
</RelativeLayout>
ViewStubは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/banner_player_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/cell_height"
android:background="@color/clr_player"
android:clickable="true" >
[...the content does not matter the height is fixe]
</RelativeLayout>
これが私が見えるようにする方法です:
public void showPlayerBanner(String title) {
if (mViewPlayer == null) {
ViewStub stub = (ViewStub) findViewById(R.id.main_stubplayer);
mViewPlayer = stub.inflate();
} else {
mViewPlayer.setVisibility(View.VISIBLE);
}
}