如何将一个字符串从适配器传递给片段,然后再传递给活动。

huangapple 未分类评论49阅读模式
英文:

How can I pass a string to Activity coming from Adapter to Fragment then to Activity

问题

这是我的Adapter部分:

Bundle bundle = new Bundle();
bundle.putString("title01", title);
bundle.putString("amount", Video1);
bundle.putString("title", chat_ID);
bundle.putString("desc", video_desc);
Navigation.findNavController(v).navigate(R.id.action_global_frag_videoplay, bundle);

这是我的Fragment部分:

String str = getArguments().getString("amount");
Intent intent = new Intent(getActivity(), FullscreenActivity.class);
intent.putExtra("key1", str);
startActivity(intent);

这是我的activity部分:

String value = intent.getStringExtra("key1");

打开活动时一直出现这个错误。

英文:

How can I pass data to activity from Adapter to Fragment then to Activity

This is my Adapter

Bundle bundle = new Bundle();
            bundle.putString("title01", title);
            bundle.putString("amount", Video1);
            bundle.putString("title", chat_ID);
            bundle.putString("desc", video_desc);
            Navigation.findNavController(v).navigate(R.id.action_global_frag_videoplay, bundle);

This is my Fragment

String str = getArguments().getString("amount");
Intent intent = new Intent(getActivity(), FullscreenActivity.class);
                intent.putExtra("key1", str);;
                startActivity(intent);

This is my activity

  String value = intent.getStringExtra("key1");

如何将一个字符串从适配器传递给片段,然后再传递给活动。

Keep getting this error when activity opens
如何将一个字符串从适配器传递给片段,然后再传递给活动。

huangapple
  • 本文由 发表于 2020年5月5日 19:18:40
  • 转载请务必保留本文链接:https://java.coder-hub.com/61611894.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定