0
현재 Viewpager Fragment 내에 2 개의 Fragments를 포함하려고합니다. 모두 정상적으로 작동하지만 두 조각을 더 스크롤하여 두 조각이있는 조각으로 돌아 가면 위쪽 조각 만 볼 수 있습니다 (조각 B는 보이지 않음). 내가 다시 이렇게하면 다시 볼 수 있습니다. onResume-Event는 Fragment B에서 호출되지만 표시되지 않습니다. 레이아웃 XML : onCreateView에서Viewpager에서 두 번째보기로 표시되는 조각
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/a_fragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/android_color_blue_dark"/>
<FrameLayout
android:id="@+id/b_fragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/android_color_green_dark" />
</LinearLayout>
부모 조각 코드()
if (v.findViewById(R.id.a_fragment) != null) {
FragmentManager mgr = getChildFragmentManager();
Fragment f = mgr.findFragmentByTag(TAG_A_FRAGMENT);
if (f == null) {
f = new FragmentA();
}
FragmentTransaction transaction = mgr.beginTransaction();
transaction.replace(R.id.a_fragment, f, TAG_S_FRAGMENT);
transaction.commit();
}
if (v.findViewById(R.id.b_fragment) != null) {
FragmentManager mgr = getChildFragmentManager();
Fragment f = mgr.findFragmentByTag(TAG_B_FRAGMENT);
if (f == null) {
f = new FragmentBLogin();
}
FragmentTransaction transaction = mgr.beginTransaction();
transaction.replace(R.id.b_fragment, f,
TAG_B_FRAGMENT);
transaction.commit();
}
나는 그들이이 Error 방지하기 위해 정적 경우에도 동적으로 그 조각을 추가 할.
페이지를 변경 한 후에 보이지 않게하고 있습니까? –
난 그냥 코드를 던져 수색 아무것도 "setVisibility"또는 뭔가의 관점에서 발견. 재미있는 사실. 스크롤 할 때마다 표시됩니다. – LeDon