Xamarin + MvvmCross 6.0 не может реализовать навигацию по вкладкам - PullRequest
0 голосов
/ 30 августа 2018

Я создаю простое приложение Xamarin с использованием MvvmCross и в настоящее время не могу реализовать навигацию по вкладкам. Я получаю исключение Mvx: viewpager или tablayout не найдены

Это моя основная деятельность:

[MvxActivityPresentation]
[Activity(Theme = "@style/MainTheme",ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | 
Android.Content.PM.ConfigChanges.ScreenSize)]
public class TabsRootView : MvxAppCompatActivity<TabsRootViewModel>
{
   protected override void OnCreate(Bundle bundle)
   {
       base.OnCreate(bundle);
       SetContentView(Resource.Layout.tabs_root_view);

       if (bundle == null)
       {
           ViewModel.ShowInitialViewModelsCommand.Execute();
       }
   }
}

Это макет просмотра моих вкладок:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <android.support.design.widget.AppBarLayout android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
        <android.support.v7.widget.Toolbar 
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            local:layout_scrollFlags="scroll|enterAlways">
        </android.support.v7.widget.Toolbar>
        <android.support.design.widget.TabLayout 
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="16dp"
            local:tabGravity="center"
            local:tabMode="scrollable" />
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.view.ViewPager 
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        local:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>

Предполагается, что это один из фрагментов содержимого моих вкладок (другой выглядит почти так же):

[MvxTabLayoutPresentation(TabLayoutResourceId = Resource.Id.tabs, ViewPagerResourceId = Resource.Id.viewpager, Title = "Bacheca", ActivityHostViewModelType = typeof(TabsRootViewModel))]
[Register(nameof(PostsView))]
public class PostsView : MvxFragment<PostsViewModel>
{
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        base.OnCreateView(inflater, container, savedInstanceState);

        var view = this.BindingInflate(Resource.Layout.posts_view, null);

        // RecyclerView
        var recyclerView = view.FindViewById<MvxRecyclerView>(Resource.Id.recycler_view);
        recyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
        recyclerView.HasFixedSize = false;

        // Swipe touch helper
        var callback = new SwipeItemTouchHelperCallback(ViewModel);
        var touchHelper = new ItemTouchHelper(callback);
        touchHelper.AttachToRecyclerView(recyclerView);

        return view;
    }
}
...