0
我有一個片段,有一個按鈕單擊事件,點擊這個按鈕,我需要啓動一個FragmentActivity,但我似乎得到錯誤,無論我試圖做到這一點。Xamarin Android的 - 從片段開始片段活動
這是在我的片段按鈕單擊事件:
myExhibitGallery.Click += delegate {
//StartActivity(typeof(MyExhibitHistoryActivity));
Intent intent = new Intent(MyExhibitHistoryActivity);
StartActivity(intent);
正如你可以看到我已經用兩種不同的方法(意向和StartActivity)試過了,但都拋出錯誤。
這是我要開始FragmentActivity:
[Activity (Label = "My Exhibit History")]
public class MyExhibitHistoryActivity : FragmentActivity
{
ViewPager _viewPager;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.MyExhibitHistory);
_viewPager = FindViewById<ViewPager> (Resource.Id.viewPager);
}
}
public class ViewFragmentAdapter: FragmentPagerAdapter
{
public ViewFragmentAdapter (Android.Support.V4.App.FragmentManager fm) : base (fm)
{
}
public override int Count {
get { return 5; }
}
public override Android.Support.V4.App.Fragment GetItem (int position)
{
return new viewerFragment();
}
}
public class viewerFragment: Android.Support.V4.App.Fragment
{
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var view = inflater.Inflate (Resource.Layout.myExhibitHistoryItem, container, false);
return view;
}
}
誰能告訴我正確的方式開始FragmentActivity好嗎?
謝謝非常! – 2014-10-30 08:44:41
不客氣! :) – 2014-10-30 09:09:58