2013-07-06 37 views

回答

1
// Create a constant in class MenuFragment   
    public final static String TAG = "MenuFragmentTag"; 

以后它可以用于创建使用findFragmentByTag片段:

getFragmentManager().findFragmentByTag(MenuFragment.TAG); 
+0

谢谢you.But如果有很多碎片,代码会很难看。那么有没有更好的方法来解决这个问题? – Marshall

+0

嘿,这是我知道什么时候片段没有在XML中定义的唯一途径。 – Permita