I did exercise A, in which there is a fragment of x. For fragment x, edit the text element on a click event, I want to open another fragment y where the list is displayed, and I just click on the name in the list, fragment y closes and sends the selected list name to fragment x to edit the text and code that I made,
YFragment y = new YFragment();
y.setTargetFragment(x.class, code);
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.frame, y)
.addToBackStack(null).commit();
and in the yi fragment I made the target code for sending data, but the problem in this block of code is higher. if I comment on the given target line of the fragment, the code will work, but useless, since the data will not be sent, but if I run the application, this error
java.lang.IllegalStateException: Fragment y {46d3d31 # 3 id = 0x7f090069} declared target fragment x {e2c16 # 0 id = 0x7f090104 android: switcher: 2131296516: 0}, which does not belong to this FragmentManager!
source
share