So, why does my log info shows completely wrong behaviour between Activity-Fragment relation?
我只是在大多数活动和片段方法上添加了日志标签,结果如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 06-19 16:33:11.934: I/Fragment Activity:MainMenuPager(15820): onCreate - BEGIN 06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onCreate - END 06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onStart - BEGIN 06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onStart - END 06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onResume - BEGIN 06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onResume - END 06-19 16:33:11.973: I/HomeFragment(15820): onAttach- BEGIN 06-19 16:33:11.973: I/HomeFragment(15820): onAttach- BEGIN 06-19 16:33:11.973: I/HomeFragment(15820): onCreate- BEGIN 06-19 16:33:11.973: I/HomeFragment(15820): onCreate- END 06-19 16:33:11.973: I/HomeFragment(15820): onCreateView- BEGIN 06-19 16:33:11.981: I/HomeFragment(15820): onCreateView- END 06-19 16:33:11.989: I/HomeFragment(15820): onActivityCreated- BEGIN 06-19 16:33:11.989: I/HomeFragment(15820): onActivityCreated- END 06-19 16:33:11.989: I/HomeFragment(15820): onStart- BEGIN 06-19 16:33:11.989: I/HomeFragment(15820): onStart- END 06-19 16:33:11.989: I/MyProcessListFragment(15820): onAttach- BEGIN 06-19 16:33:11.989: I/MyProcessListFragment(15820): onAttach- BEGIN 06-19 16:33:11.989: I/MyProcessListFragment(15820): onCreate- BEGIN 06-19 16:33:11.989: I/MyProcessListFragment(15820): onCreate- END 06-19 16:33:11.989: I/MyProcessListFragment(15820): onCreateView- BEGIN 06-19 16:33:12.012: I/MyProcessListFragment(15820): onCreateView- END 06-19 16:33:12.012: I/MyProcessListFragment(15820): onActivityCreated- BEGIN 06-19 16:33:12.012: I/MyProcessListFragment(15820): onActivityCreated- END 06-19 16:33:12.012: I/MyProcessListFragment(15820): onStart- BEGIN 06-19 16:33:12.012: I/MyProcessListFragment(15820): onStart- END |
那么为什么所有记录的活动方法都首先运行,然后是所有片段的?片段应该在各种活动状态之间运行吗???
对不起,我在这里没有看到问题。首先,你有一个寻呼机,我们不知道你设置了适配器。您是否将其设置在 onResume 中? B/c 我猜这将与您的输出相匹配。
如果您在布局中嵌入