嗨,我已經假無限ViewPager
與FragmentStatePagerAdapter
。我動態地添加CalendarFragment
到它。我有成員變量mUpdatedShiftsCont
什麼是連接點到另一個內部片段:ViewPager中的動態內部片段重疊
CalendarFragment.java:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.calendar_fragment, container, false);
mCalendarView = (GridView) rootView.findViewById(R.id.calendar);
mUpdatedShiftsCont = (FrameLayout) rootView.findViewById(R.id.calendar_updated_shifts_container);
return rootView;
}
layout.calendar_fragment:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/calendar_fragment_id"
android:orientation="vertical" >
...
<FrameLayout
android:paddingTop="30dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/calendar_updated_shifts_container" />
</LinearLayout>
當我嘗試添加內片段連接點,
getFragmentManager().beginTransaction()
.add(mUpdatedShiftsCont.getId(), fragment).commit();
所有嵌套的片段被放置在一個父片段ViewPager
:
沒有人有知道如何解決這個問題?提前致謝。
你想添加或替換你的內部片段? – santalu 2014-09-27 21:45:05
我想在'ViewPager'中將片段添加到片段。 – skywall 2014-09-27 21:56:49
檢查了這一點http://stackoverflow.com/questions/7723964/replace-fragment-inside-a-viewpager?rq=1 – santalu 2014-09-27 21:58:02