使用导航组件时如何自动加载回收器的内容..而不是活动intentPutExtra
我正在尝试在使用导航组件导航到的新屏幕上加载 recyclerView 的内容。我认为活动是intentPutExtra,或者类似的东西。
如果您能编写示例代码,我将不胜感激,但我不介意任何指示,提前致谢。我是新人,我不太愿意提供信息,所以如果您需要任何东西,我很乐意提供,提前致谢。
以下是来自 recyclerView 适配器的代码,用于导航到片段:
// binds the list items to a view
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
...
// navigates to stories content destination
holder.storiesCardView.setOnClickListener {
val action = StoriesFragmentDirections.actionNavigationStoriesToStoriesContentFragment()
holder.itemView.findNavController().navigate(action)
}
}
因此,我使用 safeArgs
(版本 2.3.1)FragmentDirections 进行导航。
如果您决定显示示例代码,我打算使用 string.xml 文件中的预定义文本。
我很想添加更多信息,但我希望信息尽可能简短。因此,如果您需要任何信息,请告诉我..再次感谢..
I am trying to load the contents of recyclerView on a new screen I navigate to using navigation components.. I think with activity it was intentPutExtra, or something like this.
I'd appreciate if you could write a sample code, but I don't mind any pointers, thanks in advance. I'm new, and I don't really to the informartion to provide, so please if you need anything I am more than happy to provide, thanks in advance.
Here's the code from the recyclerView Adapter, that navigate into the fragment:
// binds the list items to a view
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
...
// navigates to stories content destination
holder.storiesCardView.setOnClickListener {
val action = StoriesFragmentDirections.actionNavigationStoriesToStoriesContentFragment()
holder.itemView.findNavController().navigate(action)
}
}
So I'm using safeArgs
(ver 2.3.1) FragmentDirections to navigate.
Please if you decide to show a sample code, I intend to use predefined text in string.xml file.
I'd love to add more info but I want this to be short as possible. So please if you want any info let me know.. Thanks again..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
导航图中
在导航位置的
注意:CustomModel 应该是可打包或可序列化的。
在片段中检索,如下所示
At ur navgraph
at navigating place
Note:CustomModel should be Parcelable or Serializable.
at retriving in fragment like below