[mono-android] Convert .net type to Java.Lang.Object - how?
Jonathan Pryor
jonp at xamarin.com
Tue Jun 5 01:39:57 UTC 2012
On May 25, 2012, at 3:41 AM, Dariusz Sroka wrote:
> I'm using 3rd part java library and I need to use Java.Lang.Object as parameter in one of the methods.
>
> How can I convert .net custom class to Java.Lang.Object? Any examples?
You'll need to create a wrapper object:
class Holder<T> : Java.Lang.Object {
public readonly T Value;
public Holder (T value)
{
this.Value = value;
}
}
Then create a new instance when invoking Java code:
view.Tag = new Holder<LibraryType>(value);
LibraryType taggedValue = ((Holder<LibraryType>) view.Tag).Value;
- Jon
More information about the Monodroid
mailing list