2011-10-14 33 views

回答

6

我假設你想找到你知道對於活動或標籤片段的存在。上個

第一個呼叫getCurrentActivity()然後調用

getFragmentManager().findFragmentById() 

getSupportFragmentManager().findFragmentById() 

,如果您使用的是V4兼容性 庫。這將搜索頁面上的所有片段並將其返回。如果您之前已經標記了片段,則還可以使用findFragmentByTag()

+0

solo.getCurrentActivity()。getSupportFragmentManager()不起作用。它顯示我「無法解決方法」錯誤。 –

+0

然後你可能沒有在你的應用程序支持庫,這是好的,如果你只是針對更現代化的設備。在這種情況下,只需使用'getFragmentManager()'而不是'getSupportFragmentManager()' –

+0

我在我的應用程序中使用了getSupportFragmentManager(),所以有支持庫。我無法理解。 :/ –