我正在开发一个具有垂直选项卡的活动,其中一个选项卡也包含水平选项卡。当我尝试这样做时,我得到了类转换异常,因为选项卡内容应该继承 MvxFragment 并且我让它继承了 MvxTabsFragmentActivity。这是活动的代码:
using Android.App;
using Android.OS;
using Android.Views;
using Cirrious.MvvmCross.Droid.Fragging;
using Cirrious.MvvmCross.Droid.Views;
using Xyz.Yzx.ViewModels;
namespace Xyz.Yzx.Core.Views
{
[Activity(Label = "View for FirstViewModel",MainLauncher = true)]
public class FirstView : MvxTabsFragmentActivity
{
public FirstViewModel FirstViewModel
{
get { return (FirstViewModel)base.ViewModel; }
}
public FirstView()
: base(Resource.Layout.ClassMate_Page, Resource.Id.actualtabcontent)
{
}
protected override void AddTabs(Bundle args)
{
AddTab<Favourite>("Tab2", "Tab 2", args, FirstViewModel.MainViewModel);
// note that
}
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.Main, menu);
return true;
}
}
}
这是“Favorite”类(标签片段活动):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Cirrious.MvvmCross.Droid.Fragging.Fragments;
namespace Xyz.Core.Views
{
public class Favourite : MvxTabsFragmentActivity
{
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.Inflate(Resource.Layout.device_view, container, false);
}
}
}
那么如何将标签放在标签内容中?