无法将类型“Java.Lang.Object"隐式转换为“Android.Runtime.JavaDictionary<string, string>" [英] Cannot implicitly convert type &#39;Java.Lang.Object&#39; to &#39;Android.Runtime.JavaDictionary&lt;string, string&gt;

查看:25
本文介绍了无法将类型“Java.Lang.Object"隐式转换为“Android.Runtime.JavaDictionary<string, string>"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的应用程序上应用 Google Places Api 并将 Java 转换为 C# 代码.但是当我在列表中获取附近的地点时,我收到了这个错误:

I am applying Google Places Api on my app and converting the Java to C# code. But when I am getting the nearby places in the list, I got this error:

无法将类型Java.Lang.Object"隐式转换为Android.Runtime.JavaDictionary".存在显式转换(您是否缺少强制转换?)

Cannot implicitly convert type 'Java.Lang.Object' to 'Android.Runtime.JavaDictionary'. An explicit conversion exists (are you missing a cast?)

private void showNearbyPlaces(JavaList<JavaDictionary<string, string>> placeList)
    {
        for (int eachPlace = 0; eachPlace < placeList.Size(); eachPlace++)
        {

            MarkerOptions markerOptions = new MarkerOptions();
            JavaDictionary<string, string> googlePlace = placeList.Get(eachPlace); /*This is the error*/
        }
    }

代码截图

知道如何解决这个问题吗?谢谢你.

Any know how to fix this? Thank you.

推荐答案

您可以使用 System.Collections.Generic.List 而不是 JavaList,例如:

You could use System.Collections.Generic.List instead of JavaList, for example :

using System.Linq;

...

private void showNearbyPlaces(List<JavaDictionary<string, string>> placeList)
{
    for (int eachPlace = 0; eachPlace < placeList.Count; eachPlace++)
    {
        JavaDictionary<string, string> googlePlace = placeList.ElementAt(eachPlace);
    }
}

这篇关于无法将类型“Java.Lang.Object"隐式转换为“Android.Runtime.JavaDictionary<string, string>"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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