viewPager.getChildCount() onActivityResult 后归零
viewPager.getChildCount() zero after onActivityResult
我有一个 MainActivity,我在 onCreate()
中设置了一个 ViewPager
。 MainActivity 启动 CatActivity 以获得结果。在 onActivityResult
中,当我检查 viewPager 时,viewPager.getChildCount()
显示 0,而它应该显示 3.
onActivityResult 正在主线程上调用,但出于某种原因您无法从中访问视图(可能此时未重新创建视图)。
因此,您应该设置调用 onActivityResult 的标志,而不是在 onResume 中调用您的代码。
Presenter has a reference to View only between onResume/onPause.
View has a reference to Presenter any time it wants, but it is highly advisable to not request for presenter before the view state
has been restored.
onActivityResult happens before onResume, so Presenter does not have View attached
我有一个 MainActivity,我在 onCreate()
中设置了一个 ViewPager
。 MainActivity 启动 CatActivity 以获得结果。在 onActivityResult
中,当我检查 viewPager 时,viewPager.getChildCount()
显示 0,而它应该显示 3.
onActivityResult 正在主线程上调用,但出于某种原因您无法从中访问视图(可能此时未重新创建视图)。 因此,您应该设置调用 onActivityResult 的标志,而不是在 onResume 中调用您的代码。
Presenter has a reference to View only between onResume/onPause.
View has a reference to Presenter any time it wants, but it is highly advisable to not request for presenter before the view state has been restored.
onActivityResult happens before onResume, so Presenter does not have View attached