我正在处理一个具有垂直标签的Activity,其中一个标签也包含水平标签。当我尝试这样做时,我得到了类转换异常,因为选项卡内容应该继承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;
}
}
}
这是“收藏”类(Tab片段活动):
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);
}
}
}
那么如何在标签内容中添加标签?
答案 0 :(得分:5)
片段包含在http://slodge.blogspot.co.uk/2013/06/n26-fragments-n1-days-of-mvvmcross.html
中在标签中显示片段显示在https://github.com/slodge/MvvmCross-Tutorials/tree/master/Fragments
中如果您的UX需要片段内的标签,那么:
Activity
作为tabhost片段的基础。