зеркало из https://github.com/mono/mail-archives.git
116 строки
5.1 KiB
HTML
116 строки
5.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [mono-android] System.NotSupportedException with ArrayAdapter of custom object
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20System.NotSupportedException%20with%20ArrayAdapter%0A%09of%20custom%20object&In-Reply-To=68573476-2E56-4D75-AD65-8DBC314B2E58%40xamarin.com">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
<LINK REL="Previous" HREF="007755.html">
|
|
<LINK REL="Next" HREF="007780.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[mono-android] System.NotSupportedException with ArrayAdapter of custom object</H1>
|
|
<B>Jared Barneck</B>
|
|
<A HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20System.NotSupportedException%20with%20ArrayAdapter%0A%09of%20custom%20object&In-Reply-To=68573476-2E56-4D75-AD65-8DBC314B2E58%40xamarin.com"
|
|
TITLE="[mono-android] System.NotSupportedException with ArrayAdapter of custom object">rhyous at yahoo.com
|
|
</A><BR>
|
|
<I>Mon Dec 12 23:08:46 EST 2011</I>
|
|
<P><UL>
|
|
<LI>Previous message: <A HREF="007755.html">[mono-android] System.NotSupportedException with ArrayAdapter of custom object
|
|
</A></li>
|
|
<LI>Next message: <A HREF="007780.html">[mono-android] System.NotSupportedException with ArrayAdapter of custom object
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#7765">[ date ]</a>
|
|
<a href="thread.html#7765">[ thread ]</a>
|
|
<a href="subject.html#7765">[ subject ]</a>
|
|
<a href="author.html#7765">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>>><i> I am getting this error too. The documentation states this should work.
|
|
</I>
|
|
>><i> <A HREF="http://docs.monodroid.net/index.aspx?link=T%3aAndroid.Widget.ArrayAdapter">http://docs.monodroid.net/index.aspx?link=T%3aAndroid.Widget.ArrayAdapter</A>
|
|
</I>>><i>
|
|
</I>>><i> I have created a very simple sample project that duplicates this issue.
|
|
</I>>><i> <A HREF="http://www.rhyous.com/wp-content/uploads/2011/12/TestCustomObjectInArrayAdapter.zip">http://www.rhyous.com/wp-content/uploads/2011/12/TestCustomObjectInArrayAdapter.zip</A>
|
|
</I>><i>
|
|
</I>><i>I'm sorry, this is: <A HREF="http://bugzilla.xamarin.com/show_bug.cgi?id=2347">http://bugzilla.xamarin.com/show_bug.cgi?id=2347</A>
|
|
</I>
|
|
|
|
Thanks for logging the bug, Jon. I went ahead and used ArrayAdapter<String>. Then for my DeviceList, I created this extension method that just takes the value I wanted to display as a string in my list.
|
|
|
|
|
|
        // Extension method
|
|
        public static String[] Names(this DeviceList inList)
|
|
        {
|
|
            string[] deviceList = new string[inList.count];
|
|
            for (int i = 0; i < inList.count; i++)
|
|
            {
|
|
                deviceList[i] = inList.Devices[i].DeviceName;
|
|
            }
|
|
            return deviceList;
|
|
        }
|
|
|
|
Then here is the first part of my DeviceArrayAdapter where you see what I did.
|
|
|
|
    public class DeviceNameArrayAdapter : ArrayAdapter<String>
|
|
    {
|
|
        DeviceList _DeviceList;
|
|
        private int mResID;
|
|
|
|
        public DeviceNameArrayAdapter(Context c, int resID, DeviceList inDeviceList)
|
|
            : base(c, resID, inDeviceList.Names())
|
|
        {
|
|
            mResID = resID;
|
|
            _DeviceList = inDeviceList;
|
|
        }
|
|
    ....
|
|
|
|
It seems to be a good workaround for me, so I thought I would share it.
|
|
-------------- next part --------------
|
|
An HTML attachment was scrubbed...
|
|
URL: <A HREF="http://lists.ximian.com/pipermail/monodroid/attachments/20111212/fa117987/attachment.html">http://lists.ximian.com/pipermail/monodroid/attachments/20111212/fa117987/attachment.html</A>
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI>Previous message: <A HREF="007755.html">[mono-android] System.NotSupportedException with ArrayAdapter of custom object
|
|
</A></li>
|
|
<LI>Next message: <A HREF="007780.html">[mono-android] System.NotSupportedException with ArrayAdapter of custom object
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#7765">[ date ]</a>
|
|
<a href="thread.html#7765">[ thread ]</a>
|
|
<a href="subject.html#7765">[ subject ]</a>
|
|
<a href="author.html#7765">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
|
|
<hr>
|
|
<a href="http://lists.ximian.com/mailman/listinfo/monodroid">More information about the Monodroid
|
|
mailing list</a><br>
|
|
</body></html>
|