2 回答

TA貢獻1854條經驗 獲得超8個贊
如果我正確理解這一點,而不知道您擁有什么,而不查看“ fragment_container”的布局,那么我會告訴我,如果您不向其提供更多信息,則其類型ViewGroup此時只能有一個子級。
這意味著fragment_container已經有一個孩子,您需要在添加SimpleFragment.
假設您有第一個片段布局,如下所示
<someView>
? <fragment_container/>? // hear you are loading your first fragment and trying load the SimpleFragment as well which is causing problem.
</someView>
你需要的是
<someView>
? <fragment_container/>? only load First Fragment "first_fragment_layout.xml"
</someView>
在第一個片段的布局中
第一個_fragment_layout.xml
<someView>
? <viewBlasBla/>
? <viewBlasBla/>
? <fragment_container/>? load SimpleFragment here
</someView>
正如您所看到的,您確實正在嘗試執行嵌套片段,這不是一個好的實踐。如果可能的話盡量避免這種情況:)。
添加回答
舉報