There is something very strange going on that nabble.com has full content but 
the email does not; compare:

        http://lists.ximian.com/pipermail/monodroid/2012-May/010297.html
        
http://mono-for-android.1047100.n5.nabble.com/Mono-for-Android-4-2-1-SimpleExpandableListAdapter-problems-td5709314.html#a5709775

The first is what I see, the second contains actually useful stack traces...

On May 15, 2012, at 3:57 PM, Jones wrote:
> replacing Dictionary with JavaDictonary solved the  class cast exception. But 
> then I got this message:
> 05-15 21:45:04.444 E/AndroidRuntime( 6384): FATAL EXCEPTION: main
> 05-15 21:45:04.444 E/AndroidRuntime( 6384): java.lang.ClassCastException: 
> mono.android.runtime.JavaObject cannot be cast to java.lang.String

So the problem is that I need to make things slightly more magical. ;-)

In the meantime, SimpleAdapter is wanting your values to be strings. Not 
System.Strings, but Java.Lang.Strings, so you need:

        foreach (Genre genre in genres) {
                using (var group = new JavaDictionary<string, object>()) {
                        group[name] = new Java.Lang.String (genre.Name);
                        group[id] = new Java.Lang.Integer(genre.Id);    // may 
or may not be necessary...
                        groupData.Add (group);
                }
        }

Or, looking at the original message:

        var settings_data = new JavaList<IDictionary<string, object>>();

        sa = Resources.ObtainTypedArray(Resource.Array.settings_text);
        sa_icons = Resources.ObtainTypedArray(Resource.Array.settings_icons);

        for (int i = 0; i < sa.Length(); i++)
        {
                using (var item = new JavaDictionary<string, object>()) {
                        item["text"] = new Java.Lang.String (sa.GetString(i));
                        item["icon"] = new Java.Lang.Integer 
(sa_icons.GetResourceId(i, 0));
                        settings_data.Add(item);
                }
        }

        this.ListAdapter = new SimpleAdapter(this, settings_data,
                        Resource.Layout.list_item_icon_text, new String[] { 
"text", "icon" },
                        new int[] { Resource.Id.text, Resource.Id.icon });

 - Jon

_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to