[英]How to switch to the first fragment when selecting an item from the recyclerView of second Fragment? Both fragments are in tablayout with viewPager2
When I click an item from the SongList fragment, it should automatically switch to the NowPlaying fragment.当我从 SongList 片段中单击一个项目时,它应该会自动切换到 NowPlaying 片段。 Also how will I send the item position of the selected song from the recyclerView of the SongList fragment to the NowPlaying fragment?
另外,我如何将所选歌曲的项目 position 从 SongList 片段的 recyclerView 发送到 NowPlaying 片段? Thanks.
谢谢。
Access your NavController in your Fragment with getParentFragmentManager().findFragmentById(R.id.fragment_container_view)
and call .navigate(R.id.now_playing)
.使用
getParentFragmentManager().findFragmentById(R.id.fragment_container_view)
访问 Fragment 中的 NavController 并调用.navigate(R.id.now_playing)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.