How to convert a generic list from and to Java.Lang.Object in Mono for Android

喜夏-厌秋 提交于 2019-12-12 02:18:40

问题


Now I'm facing this problem and don't know about a solution yet. The doc on Xamarin is pretty vague to me on this matter. The fact that Java Generics are implemented as type erase which is quite different from .NET's approach also makes the matter quite complex. Could anyone point me to the right direction? It seems that the generic type parameter should implement IJavaObject, but I did this and it does not work in this case.


回答1:


I think I'll have to answer it myself. After contacting Xamarin, in the case of using a list to do things which requires it to be a IJavaObject, you'd better off with JavaList instead of List which also implements IList. JavaList actually is just a wrapper around java.util.ArrayList



来源:https://stackoverflow.com/questions/12527408/how-to-convert-a-generic-list-from-and-to-java-lang-object-in-mono-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!