我有一个片段我正在给导航抽屉充气。导航抽屉有自己的片段。为了通过抽屉获取当前内容,我将当前片段视图在充气后插入抽屉。这有效,但如果我给抽屉充气,它就不再与它的碎片相关联。如何对片段内的片段进行充气,并将其保持附加到片段代码?
ViewGroup decor = (ViewGroup) getActivity().getWindow().getDecorView();
View child = decor.getChildAt(0);
View view = inflater.inflate(R.layout.log_entry_fragment, container, false);
DrawerLayout drawerLayout = (DrawerLayout)
inflater2.inflate(R.layout.fragment_navigation_drawer, null);
FrameLayout container2 = (FrameLayout) drawerLayout.findViewById(R.id.content_frame);
container2.addView(child);