答案 0 :(得分:1)
无法将类型'Java.Lang.Object'隐式转换为'Android.Runtime.JavaDictionary'。存在显式转换(您是否错过了演员?)
我注意到在previous question中,placeList的类型为JavaList
,
您应该注意JavaList.Get(position)
返回Java.Lang.Object
的类型。您无法直接将其转换为JavaDictionary
。
JavaList
Get(int location)
方法:
public class JavaList : Java.Lang.Object, System.Collections.IList, System.Collections.ICollection, IEnumerable
{
...
public virtual Java.Lang.Object Get(int location);
}
正如@Jon Douglas所说,你可以使用JavaCast:
JavaDictionary<string, string> googlePlace = placeList.Get(eachPlace).JavaCast<JavaDictionary<string, string>>();
您可以使用System.Linq
:
JavaDictionary<string, string> googlePlace = placeList.ElementAt(eachPlace);
using System.Linq;
...
private void showNearbyPlaces(JavaList<JavaDictionary<string, string>> placeList)
{
for (int eachPlace = 0; eachPlace < placeList.Count; eachPlace++)
{
JavaDictionary<string, string> googlePlace = placeList.ElementAt(eachPlace);
string reference = googlePlace["reference"];
double lat = System.Double.Parse(googlePlace["lat"]);
}
}