甚至可以从调用Activity访问Fragment中的Views。或者我必须在调用Bundle
时将所有必需的信息放入NewInstance
或在我的片段中使用静态方法
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.ActivityNavigationLayout);
var button = FindViewById<Button>(Resource.Id.Button);
}
private void SetUpFragmentManager()
{
var frag = OverViewFragment.NewInstance();
var fm = this.FragmentManager.BeginTransaction();
fm.Replace(Resource.Id.content_frame, frag);
fm.Commit();
}
当Resource.Id.Button
是Fragment在该Activity内部膨胀的一部分时?
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View rootView = inflater.Inflate(Resource.Layout.Main, container, false);
return rootView;
}