I tried this: ((MainActivity) getActivity (). GetSupportFragmentManager (). BeginTransaction (). Remove (this);

But so a mistake.

Closed due to the fact that off-topic participants YuriySPb , Kromster , Vadim Ovchinnikov , Denis Bubnov , aleksandr barakin Jan 27 '17 at 16:04 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - YuriSPb, Kromster, Vadim Ovchinnikov, Denis Bubnov
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Show something wrong. - tse
  • Inconvertible types; cannot cast int - Fedia

2 answers 2

remove (android.support v4.app.Fragmernt) in FragmentTransaction cannot be applied to (anonimus android.view.View.onclicklistener)

If you did this inside the listner, this refers not to your Fragment, but to an instance of an anonymous class, which is your listner. You need

....remove(YorFragment.this) 
  • After this, the second error: Inconvertible types; cannot cast int - Fedia
  • Oh. Is everything ok with the brackets? - tse
  • no, s '' - too many characters in character literal - Fedia
  • and with "" - in FragmentTransaction cannot be applied to (java.land.string) - Fedia
  • Show the full line. - tse

What a mistake, you do not write, but just forgot .commit() at the end of this expression.

  • remove (android.support v4.app.Fragmernt) in FragmentTransaction cannot be applied to (anonimus android.view.View.onclicklistener) - Fedia