Poperto Arcadio Buendía Poperto Arcadio Buendía - 3 months ago 34
Android Question

How to know if a Fragment is Visible?

I'm using the support library v4 and my questions are, How to know if a Fragment is Visible? and How can I change the propierties of the Layout inflated in the Fragment? Thanks in advance.

---Edit---

I'm using fragments like in the android developers tutorial with a FragmentActivity

Answer

You should be able to do the following:

MyFragmentClass test = (MyFragmentClass) getSupportFragmentManager().findFragmentByTag("testID");
if (test != null && test.isVisible()) {
     //DO STUFF
}
else {
    //Whatever
}
Comments