相关疑难解决方法(0)

如何使用Navigation Architecture Component从片段中获取结果?

假设我们有两个片段:MainFragmentSelectionFragment.第二个是用于选择某个对象的构建,例如整数.从第二个片段接收结果有不同的方法,如回调,总线等.

现在,如果我们决定使用导航架构组件导航到第二个片段,我们可以使用以下代码:

NavHostFragment.findNavController(this).navigate(R.id.action_selection, bundle)
Run Code Online (Sandbox Code Playgroud)

其中bundleBundle(当然)的实例.正如您所看到的那样,无法访问SelectionFragment我们可以进行回调的位置.问题是,如何使用Navigation Architecture Component接收结果?

android android-architecture-components android-jetpack android-architecture-navigation

24
推荐指数
5
解决办法
6230
查看次数