![](/img/trans.png)
[英]Child fragment's parent returns NavHostParent instead of actual parent fragment
我有以下結構: 我想從ChildFragment類訪問Fragment1或Fragment2 ,但是當我調用parentFragment時,它會返回NavHostFragment 。 我無法通過 id 或 tag 直接搜索 Fragment1 或 Fragment2,因為您可以看到父級可能會更 ...
[英]Child fragment's parent returns NavHostParent instead of actual parent fragment
我有以下結構: 我想從ChildFragment類訪問Fragment1或Fragment2 ,但是當我調用parentFragment時,它會返回NavHostFragment 。 我無法通過 id 或 tag 直接搜索 Fragment1 或 Fragment2,因為您可以看到父級可能會更 ...
[英]Data reset when moving from one to another fragment using Bottom Navigation Bar
我在我的項目中使用底部導航欄和片段。 當它從一個片段移動到另一個片段時,我不想丟失 state 或數據我該怎么做? 這是 activity_main.xml 這是 MainActivity.java 這是我正在使用 PhoneFragment.java 的片段之一 請告訴我如何在移動到另一個片段時不 ...
[英]How to refresh fragment by clicking on button
我想通過單擊它的按鈕來刷新我的片段。 怎么做? 我嘗試這樣做,但舊版本的片段出現在屏幕頂部(附圖片): ...
[英]Reload Fragment after popBackStack
我需要在這個過程 Go 從片段 A 到片段 B 和 go 從片段 B 到片段 C 之后重新加載片段,然后進行注冊過程,注冊正確后,popBackStack 片段 A 和我的片段 A 將被重新加載。 我的主要問題是片段 A 沒有重新加載 請幫助我 ...
[英]I'm trying to create a spinner in a Fragment and fill it using ArrayList but the app keeps crashing
這是我第一次在 Android 中使用 Fragments,我正在嘗試創建一個微調器並使用 ArrayList 填充它。 我的應用程序在主屏幕上有 3 個按鈕,第一個按鈕用這個片段替換了 Activity 中的 FrameLayout,但是一旦我按下它,應用程序就會崩潰。 我必須制作另外兩個片段,但 ...
[英]Is there a way to dynamically create fragments and display data to them using the same layout?
我編寫了從遠程端點獲取 JSON 對象的代碼。 對於這個問題,我傳入了一個模擬對象,它是一個對象數組。 我的目標是解構對象,並為數組的每個元素在 ViewPager 中創建一個片段。 每個片段都應該顯示它所代表的對象的 id。 該對象如下所示: 如果我取消對 FragmentClass 中的代碼 ...
[英]Fragment is not starting from menu item when pressed
我正在嘗試從工具欄啟動一個片段(工具欄也在一個片段中)但它沒有啟動,當它在主要活動中它工作正常時不是這種情況。 如果您想要任何文件的更多參考或想查看其他文件,請告訴我我會上傳 Java 文件首頁_Fragment.java XML 文件 tool_bar.xml(菜單 XML) 工具欄.xml ...
[英]Does findFragmentById take in a FrameLayout rather than a Fragment?
我是Fragments概念的新手在我正在觀看的視頻中,他們使用了這段代碼: 通過 java 創建Fragment 。 在findFragmentById他們傳入FrameLayout (my_container) 而不是Fragment 。 我在文檔中讀到您可以傳入容器 id,但這讓我感到困惑,它 ...
[英]FragmentManager field null android
所以我試圖通過單擊我的 BottomNavigationView 中的一個選項卡來切換到另一個片段,但我不斷收到 NullPointer 異常。 我嘗試將 xml 文件中的fragment標簽更改為androidx.fragment.app.FragmentContainerView但我仍然遇到相 ...
[英]FragmentContainerView in ViewHolder - which is the appropriate FragmentManager?
我為RecyclerView連續包含一個片段 - 我知道這不是最推薦做的事情,但它使用得不多,我希望它作為一個Fragment ,因為我們在多個地方使用它。 我在ViewHolder的視圖中添加了這個: 它按預期加載,但問題是如何訪問正確的 FragmentManager 來配置片段? 文檔指出 ...
[英]java.lang.IllegalStateException ConstraintLayout does not have a NavController set for a fragment
我有一個包含三個片段(第一個、第二個和第三個)的活動( main )。 我使用<include layout="@layout/content_main"/>在我的活動( activity_main.xml )中包含了 3 個片段。 content_main.xml正在使用id = ...
[英]Activity's incapability with androidx
我遇到了一個與 Activity 的 getFragmentManager() 與 androidx.FragmentManager 不一致的問題。 所以我有以下方法: 在這里我收到錯誤"Can not resolve method show(android.app.FragmentManag ...
[英]Cannot resolve method super() error in fragmentmanager Android
我不是 Java 編碼員,而是在嘗試學習 Java 的同時嘗試構建應用程序。 我正在嘗試添加 2 個片段,一個是登錄片段,一個是注冊片段,但是在使用超級構造函數時,我面臨無法解決錯誤。 誰能建議我做錯了什么? 我知道 super 用於訪問父類構造函數,在我的情況下它不是空的。 以下是 MainA ...
[英]Where is the supportFragmentManager variable defined?
我正在使用 Kotlin 進行開發。 當我到達官方 Android 教程的片段部分時,我遇到了 supportFragmentManager。 它可用作 Kotlin 中的變量,而在 java 中,我們可以調用其等效方法getSupportFragmentManager() 。 我想知道suppo ...