如何知道一个片段可见? [英] How to know if a Fragment is Visible?

查看:112
本文介绍了如何知道一个片段可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是支持库V4和我的问题是,如何知道一个片段可见?我怎样才能改变片断虚增布局的propierties?先谢谢了。

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.

---编辑---

教程与FragmentActivity

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

推荐答案

您应该能够做到以下几点:

You should be able to do the following:

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

这篇关于如何知道一个片段可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆