In fact, it was not a long time ago, but now I want to record it. Go to the topic.
Currently, there are 4 fragment items, of which 3 are level-1 navigation items. The actionbar provides a list to access each fragment. The judgment is to write an internal class in mainactivity to implement onnavigationlistener. Because the fourth fragment enters from the third fragment by clicking list item, the problem is whether the actionbar is displayed or the navigation list, but when getactionbar () in the onresume method (), after setting the actionbar attribute and entering the fourth fragment, the title is normal. However, when the title bar is returned to the last level of fragment, It is not returned. This problem occurs because several fragment activities are parasitic on the same activity, and the actionbar is activity rather than fragment.
However, if onnavigationlistener is implemented in all fragment, it is too costly. Therefore, it is converted from an internal class to an external class, And fragmentmanager is transmitted for each fragment or activity. This reduces the number of duplicates.Code.
The problem occurs again.ProgramThe first fragment appears constantly in oncreate... The root cause is not found, so record it.
--------------------------------------------- 5/21 -------------------------------------------
The current idea of this problem may be that the first fragment is displayed by default because there is only one activity. However, onnavigationlistener is also set in this fragment, and the loop continues...
The solution has not been created yet. I want to write it again.