【发布时间】:2020-06-11 05:48:56
【问题描述】:
【问题讨论】:
-
您好,您能否使用内联代码来提高代码清晰度? link
标签: android kotlin navigation arguments
【问题讨论】:
标签: android kotlin navigation arguments
您现在可以尝试将数据作为捆绑包发送并检查它是否正常工作。我目前面临同样的问题。让我们都弄清楚。我现在这样做了:
在 startFragment 中
var bundle = Bundle()
bundle.putParcelable("object",song)
v.findNavController().navigate(R.id.action_songListFragment_to_playerFragment,bundle)
在接收片段中
val mSong = arguments?.getParcelable<Song>("object")
v.findViewById<TextView>(R.id.tv_title).text = mSong?.title
Toast.makeText(context, "${mSong?.title}", Toast.LENGTH_SHORT).show()
等我弄明白了就贴在这里。
【讨论】: