0
我有一個包含兩個Fragment
的活動,現在我希望它們在創建Activity
時不可見,我將根據用戶輸入顯示片段。使片段在初始化時不可見
於是,我就在設置佈局文件的Fragment
invisbile:
<fragment
android:name="com.app.ui.ArticleListFragment"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/poiSearchFrag"
android:visibility="gone"></fragment>
<fragment
android:name="com.app.ui.ArticleReaderFragment"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/routeSearchFrag"
android:visibility="gone"></fragment>
但似乎這是行不通的。
如何解決?
「看起來不起作用」是什麼意思 – Blackbelt
當活動開始時,兩個碎片都是可見的。 – hguser
嘗試以編程方式使用fragmenttransaction的hide()方法代替。 – bakriOnFire