工具列表
setBundle :为 fragment 设置 arguments,返回 FragmentsetArguments :为 fragment 设置 arguments,返回对应类bundleK :fragment 中 获取 arguments 的值
使用示例
class TestFg : Fragment() { //初始化 fragment 并传值 companion object { private const val key = "key" fun newInstance(): TestFg = TestFg().setArguments(key to "hello") fun newInstance2(): Fragment = TestFg().setBundle(key to "value") } //获取传值 val value by bundleK<String>(key) //获取传值,带默认值 val value2 by bundleK<String>(key){ "默认值" } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) }}