Android MapFragment作为MvvmCross中的自定义控件 [英] Android MapFragment as custom control in MvvmCross

查看:103
本文介绍了Android MapFragment作为MvvmCross中的自定义控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,在其中可以使用MapFragment或SupportMapFragment作为自定义控件. 我尝试将自定义控件( N-18 )和Fraggle(

I'm working on a project in which I can use MapFragment or SupportMapFragment as a custom control. I tried to mix custom control(N-18) and Fraggle(N-26) tutorial but I can't make it work.

我的自定义控件类:

public class CustomMapView : MvxFragment
{
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        var ignored = base.OnCreateView(inflater, container, savedInstanceState);
        return this.BindingInflate(Resource.Layout.CustomMapViewLayout, null);
    }
}

我的CustomMapViewLayout.axml

My CustomMapViewLayout.axml

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />

在FirstView.axml中,我引用了CustomMapView:

In the FirstView.axml I reference the CustomMapView:

<cc.CustomMapView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

(我在Setup.cs中使用ViewNamespaceAbbreviations)

(I use the ViewNamespaceAbbreviations in the Setup.cs)

当我尝试部署时出现以下错误:

When I try to deploy I get these errors:

MvxBind:找不到错误视图类型-cc​​.CustomMapView(我确定名称空间正确) Android.Views.InflateException:正在加载...

MvxBind:Error View Type Not Found - cc.CustomMapView (I'm sure the namespace is correct) Android.Views.InflateException:Loading...

有没有人设法解决这种问题?

Is there anybody who managed to solve this kind problem?

推荐答案

据我所知,片段必须在FragmentActivity父对象中使用,并且必须使用fragment xml标签或使用(支持)用于在父视图组中动态加载的片段管理器方法.

As far as I know, fragments have to be used within FragmentActivity parents and have to be loaded either using the fragment xml tag or using one of the (support) fragment manager methods for dynamic loading within a parent viewgroup.

正在报告View Type Not Found - cc.CustomMapView的Mvx代码绝对无法工作-它正在寻找一个在该命名空间中继承Android View的类,而不是在寻找Fragment.

The Mvx code which is reporting View Type Not Found - cc.CustomMapView definitely won't work - it's looking for a class which inherits Android View in that namespace, not looking for a Fragment.

也许有写更多动态"片段xml代码的方法-但是尚未有mvvmcross贡献者发掘出任何这些方法.现在,我认为您必须更常规地"使用片段",就像 N = 26个样本

There may be ways to write more 'dynamic' fragment xml code - but none of the mvvmcross contributors have unearthed any of these yet. For now, I think you'll have to use the Fragments more 'conventionally' - like the ways shown in the N=26 sample

这篇关于Android MapFragment作为MvvmCross中的自定义控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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