那么,为什么我的日志信息显示活动片段之间的联系完全错误的行为吗?我的、片段、错误、行为

2023-09-12 06:02:21 作者:觅得良人宠我千秋万世

我只是把日志标签上的大多数活动和片段的方法,这是结果:

I just put log tags on most activity and fragment methods and this is the result:

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

那么,为什么所有的登录活动方式运行所有的第一,那么所有的片段的人???应该一个人的各种活动状态???之间运行片段

So why all the logged activity methods run all first and then all Fragment ones???should the fragment one's run between the various activity states???

推荐答案

对不起,我没有看到一个问题在这里。首先,你有一个寻呼机,我们不知道在一个点上设置的适配器。你要为它onResume?二/三我猜这将匹配与你的输出。

Sorry I dont see an issue here. First, you have a pager, and we don't know at one point you set the adapter. Are you setting it in onResume? B/c I'm guessing that would match up with your output.

你看到什么样的输出,如果你嵌入<片段/> 的布局?你会看到,如果你通过 FragmentTransaction 与-中添加一个片段一个onClick监听什么样的产出?这些都会有不同的日志记录的结​​果所以这里的问题是,更多的是玩猜猜我是怎么写我的code的。

What kind of output do you see if you embed a <fragment /> in the layout? What kind of output would you see if you add a fragment via FragmentTransaction with-in an onClick listener? These would all have different logging outcomes so the question here is more of a game of "guess how I wrote my code".