I'm transferring data from one fragment to another using bundle my code is perfectly fine but I'm getting No view found for fragment one
I'm uploading the code of one fragment that is sending the data to another here it is
Also the code of one that is getting the data
now please tell me what should I do . I have a tab layout under which I have View Pager and in this view pager I have three different fragments and all I want to do is transfer data from one fragment to another … Please help

- 65
- 9
2 Answers
Basically, you are using the wrong approach or the wrong way to sending data from one fragment to another. You are using ViewPager with TabLayout so every tab item has its own fragment and you are calling the second tab item's fragment in the first tab item. That's not correct!
Use ViewModel for sending data between two fragments. Your issue will be resolve. See the documentation.

- 1,266
- 10
- 17
Try to update getChildFragmentManager in place of getSupportFragmentManager inside Fragment
or just try the below way inside mainActivity and call from where you want
public void changeFragmentFrom(Fragment targetFragment, byte state) {
try {
if (defaultState == state)
return;
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
ft.replace(R.id.main_layout, targetFragment, "" + state);
ft.addToBackStack("" + state);
defaultState = state;
ft.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
Please try to implement this way if your requirement match in given link
Can't use androidx.fragment.app.FragmentManager in ViewPager2
Image not shown in ViewPager2 (when Fragment reopened)
hope it may help you

- 1,143
- 1
- 9
- 6