【问题标题】:MvvmCross Dialog Navigation DrawerMvvmCross 对话框导航抽屉
【发布时间】:2013-12-27 13:04:29
【问题描述】:

我找到了一篇关于在 MvvmCross 中使用它的好博文,但我想在 MvvmCross Monodroid.Dialog 应用程序中使用它。有没有人设法让它工作?

我的操作中有以下内容:

Root = new RootElement{ 
    new Section{
        new ViewElement("page_home_view")
    }
};

并确保 page_home_view.axmlitem_menu.axml 在布局文件夹中。

但是我收到以下错误:

[Android.Dialog] Inflate failed: Didn't find class "Mvx.MvxListView" on path: /data/app/SomeApp.Mobile.Droid-1.apk
[Android.Dialog] ViewElement: Failed to load resource: page_home_view 

目前我只想打开一个带有布局的对话框,这样我就可以在之后添加所有功能。

为什么它不知道MvxListView 是什么?

这是视图的完整 XML:

<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"> <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" /> <!-- The navigation drawer -->
    <Mvx.MvxListView
        local:MvxBind="ItemsSource MenuItems; ItemClick SelectMenuItemCommand"
        local:MvxItemTemplate="@layout/item_menu"
        android:id="@+id/left_drawer"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:choiceMode="singleChoice"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#111" /> </android.support.v4.widget.DrawerLayout>

[更新]

好的,所以我不能从 monodroid.dialog mvvmcross 活动中调用 SetContentView(Resource.Layout.page_home_view);

现在我的对话活动中有以下内容:

protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate (bundle);

        //SetContentView(Resource.Layout.page_home_view);

        var bindings = this.CreateInlineBindingTarget<CategoriesViewModel>();

        Root = new RootElement{ 
            new BindableSection<CustomViewElement>(string.Empty, () => new CustomViewElement(this))
                .Bind(bindings, element => element.ItemsSource, vm => vm.Categories),
            };


        this.ActionBar.SetDisplayHomeAsUpEnabled(false);
        this.ActionBar.SetHomeButtonEnabled (true);

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



        this._drawer = view.FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
        this._drawerList = view.FindViewById<MvxListView>(Resource.Id.left_drawer);

        _drawer.SetDrawerShadow(Resource.Drawable.drawer_shadow_dark, (int)GravityFlags.Start);

        this._drawerToggle = new MyActionBarDrawerToggle(this, _drawer,
            Resource.Drawable.ic_drawer_light,
            Resource.String.drawer_open,
            Resource.String.drawer_close);

        //You can alternatively use _drawer.DrawerClosed here
        this._drawerToggle.DrawerClosed += delegate
        {
            //this.ActionBar.Title = this._title;
            this.InvalidateOptionsMenu();
        };


        //You can alternatively use _drawer.DrawerOpened here
        this._drawerToggle.DrawerOpened += delegate
        {
            //this.ActionBar.Title = this._drawerTitle;
            this.InvalidateOptionsMenu();
        };

        _drawer.SetDrawerListener(this._drawerToggle);
    }

但是什么都没有连接...

单击操作栏中的按钮不会执行任何操作。

【问题讨论】:

  • 我开始认为我需要向 monodroid.dialog 添加片段支持才能使其正常工作。我的假设是否正确?
  • 你一开始提到的博文的链接是什么?

标签: android xamarin xamarin.android mvvmcross navigation-drawer


【解决方案1】:

有没有机会忘记定义本地命名空间?

xmlns:local="http://schemas.android.com/apk/res-auto"

确保您在 XML 文件的根节点中定义了 XML 命名空间,请参见下面的示例:

【讨论】:

  • 为相关视图添加了完整的 xml。
猜你喜欢
  • 1970-01-01
  • 2018-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多