如何使用带有MvvmCross MvxTabsFragmentActivity的Android Xamarin创建选项卡 [英] How to create Tabs using Android Xamarin with MvvmCross MvxTabsFragmentActivity

查看:96
本文介绍了如何使用带有MvvmCross MvxTabsFragmentActivity的Android Xamarin创建选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在MVVMCross xamarin解决方案的android项目中实现ViewPager的选项卡控件.绑定在Windows Phone应用程序中正常工作,因此我认为Viewmodel正常工作.

I'm trying to implement a tabs control of ViewPager inside the android project of a MVVMCross xamarin solution. The binding is working in the windows phone app so i assume the Viewmodel is working.

我有一个继承了MvxTabsFragmentActivity的活动,我想将Tabs添加到其中.我的应用无法检测到ID:Resource.Id.actualtabcontent.

I have an activity that inherits MvxTabsFragmentActivity that i want to add Tabs into. My app can not detect the id : Resource.Id.actualtabcontent.

这是我尝试过的方式,( https://github.com/Cheesebaron/Cheesebaron.MvvmCross.Bindings/blob/master/Bindings.Droid/BindableViewPager.cs ) 以及尝试这个 https://github.com/MvvmCross/MvvmCross-Tutorials /tree/master/Fragments/FragmentSample.UI.Droid

This is how i Attempted it, (https://github.com/Cheesebaron/Cheesebaron.MvvmCross.Bindings/blob/master/Bindings.Droid/BindableViewPager.cs) as well as attempting this https://github.com/MvvmCross/MvvmCross-Tutorials/tree/master/Fragments/FragmentSample.UI.Droid

有人对我们如何解决这个问题有任何想法吗?

Does anyone have any idea about how we can solve this?

基本上,我们有一个父视图模型,其中包含一个LIst集合,但是我们正在努力使绑定在android内部工作.我们甚至尝试创建一个仅带有选项卡的新应用程序,有什么想法吗?

basically we have a parent viewmodel with a collection of LIst inside of it, but we are struggling to get the binding to work inside of android. we have tried even creating a new app with just the tabs in it, any ideas?

推荐答案

我不会使用MvxTabsFragmentActivity,因为它有点过时了.该示例是最新的示例: https://github.com/MvvmCross/MvvmCross-AndroidSupport/tree/master /样本

I wouldn't use MvxTabsFragmentActivity as it is a bit outdated. This sample is the latest available: https://github.com/MvvmCross/MvvmCross-AndroidSupport/tree/master/Samples

您的布局应如下所示:

<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.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.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="fill_parent"
    local:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>

TabLayout为您创建选项卡.

The TabLayout makes the tabs for you.

这篇关于如何使用带有MvvmCross MvxTabsFragmentActivity的Android Xamarin创建选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆