Ollie C
Ollie C

Reputation: 28509

ActionBar navigation tabs showing fragments on top of each other

I have an ActionBar with various navigation tabs on it. I am finding that in some circumstances (I do not understand them fully) fragment content is appearing on top of fragment content.

i.e. I visit one tab, then click a button that swaps the fragment for another, then click one of the other tabs, and the fragment content from the initial tab click is visible under the new fragment content. It seems I've built an app where it's possible to use the navigation to place fragment content on top of other fragment content, which is not what I want.

How can I ensure that when updating fragment content, the old content is removed correctly?

Upvotes: 0

Views: 980

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006674

How can I ensure that when updating fragment content, the old content is removed correctly?

You are the one creating the FragmentTransaction that is being applied by the TabListener. In that FragmentTransaction, you are telling Android what fragments to add, what fragments to remove, etc. Make sure you are setting up the FragmentTransaction objects with the business rules you want.

Upvotes: 1

Related Questions