When I press a button, my app creates a fragment. I’d like to make sure that only one of this fragment is created, e.g. disable the button if the fragment already exists.
How do I check that it creates only one fragment? Is it possible to get a Fragment count or is there some option that limits it to creating only one?
You can use the methods that sandrstar mentioned. When attaching a fragment u can first check to see if its already attached.
For example if you are adding the fragment dynamically you can stop the fragment from being re-added by doing the following: