2013-05-15 49 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