我有一个类TitleView扩展了LinearLayout,里面有一个按钮。由于servral UI需要这个类,我将它包含在那些布局xml文件中。现在我需要在按下按钮后启动PreferenceFragment,但我不能使用getFragmentManager()来获取FragmentManager来控制TitleView中的PreferenceFragment。
任何人都可以帮助我吗?非常感谢:)
答案 0 :(得分:1)
class TitleView extends LinearLayout
{
private FragmentActivity mActivity;
/**
* @param of type null
* @return mActivity of type FragmentActivity
* getter function for mActivity
* @since May 3, 2013
* @author rajeshcp
*/
public FragmentActivity getmActivity() {
return mActivity;
}
/**
* @param mActivity of type FragmentActivity
* @return of type null
* setter function for mActivity
* @since May 3, 2013
* @author rajeshcp
*/
public void setmActivity(FragmentActivity mActivity) {
this.mActivity = mActivity;
mActivity.getSupportFragmentManager();
}
public TitleView(Context context) {
super(context);
}
}
((TitleView)findViewbyId(R.id.your_lay_out_id)).setmActivity(yourFragmentActivity);
mActivity.getSupportFragmentManager();