简体   繁体   English

如何在 Android 导航组件中从片段导航到活动?

[英]How to navigate from fragment to Activity in Android navigation component?

In navigation graph, i have an Activity(MainActivity) which contains 4 fragments.在导航图中,我有一个包含 4 个片段的 Activity(MainActivity)。 I navigate that fragments using bottomnavigation view through NAV Graph (JetPack Navigation) .我通过NAV Graph (JetPack Navigation)使用底部导航视图导航这些片段。 I need to play video using Exo Player.我需要使用 Exo Player 播放视频。 So for that reason.所以出于这个原因。 i take a fragment which contains recyclerview of videolist.我拿了一个片段,其中包含 videolist 的 recyclerview。 when i pass the intent from VideoListAdapter Class like当我从 VideoListAdapter Class 传递意图时

             Intent intent=new Intent(context,PlayVideo.class);
             context.startActivity(intent);

for playing full screen video in PlayVideo Actvity在 PlayVideo 活动中播放全屏视频

it shows me error of marshal value, & parcel.write.os() , so what have to do?...Please help me.它向我显示了marshal 值和 parcel.write.os()的错误,那么必须做什么?...请帮助我。

Since you are using navigation component in your app I suggest that you should use fragments instead of Activity.由于您在应用程序中使用导航组件,我建议您应该使用片段而不是 Activity。

A quick fix for your problem would be to hide the bottom navigation view.快速解决您的问题是隐藏底部导航视图。 You can access your bottom navigation using:您可以使用以下方式访问底部导航:

BottomNavigationView navBar = getActivity().findViewById(R.id.bottomBar);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM