2013-05-15 83 views
2

訪問基地的活動我有我的片段自定義佈局,延伸RelativeLayout的機器人 - 從自定義佈局

public class Footer extends RelativeLayout 

如何使用getSupportFragmentManager從該自定義對象?當我使用this.getContext()它給應用程序,而不是FragmentActivity。

The method getSupportFragmentManager() is undefined for the type Footer (extends RelativeLayout) 

等待您的幫助

感謝

回答

0

將上下文中構造這樣

讓你的活動是MyFragmentActivity

MyFragmentActivity activity; 
Footer(MyFragmentActivity activity) 
{ 
this.context=context; 
} 

,並從你的活動發送活動名稱。這

MyFragmentActivity.this 

現在你可以使用

activity.getSupportFragmentManager() 
+0

偉大工程:)非常感謝你 – dracula