I created a navigation drawer. Now,navigation drawer requires all fragments. I want to send some information and move to this fragment which contains drawer from an activity. How do I implement this ? I am using Intent(activityclass.this,fragment.class)
for navigation and putExtra
for sending data. But the app crashes.
答案 0 :(得分:0)
Fragments are not loaded using Intent. You need to use FragmentManager:
Fragment fragment = new MyFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container,fragment).commit();
答案 1 :(得分:0)
your approach needs some modification i would like to refer the below links for better ways