[Mono-bugs] [Bug 679564] New: [generator] SmipleExpandableListAdapter generates ClassCastException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Mar 14 18:17:28 EDT 2011


https://bugzilla.novell.com/show_bug.cgi?id=679564

https://bugzilla.novell.com/show_bug.cgi?id=679564#c0


           Summary: [generator] SmipleExpandableListAdapter generates
                    ClassCastException
    Classification: Mono
           Product: MonoDroid
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Class Libraries
        AssignedTo: mkestner at novell.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US)
AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.127 Safari/534.16

Reported on:
http://lists.ximian.com/mailman/private/monodroid/2011-March/003643.html

Mono for Android port of:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ExpandableList3.html

A ClassCastException is generated when executing the following code:

    using System;
    using Android.App;
    using Android.Content;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.OS;
    using System.Collections.Generic;
    namespace MonoAndroidApplication2
    {
        [Activity(Label = "Expandable List Activity", MainLauncher = true )]
        public class Activity1 : ExpandableListActivity
        {
            IExpandableListAdapter mAdapter;
            String NAME = "NAME";
            String IS_EVEN = "IS_EVEN";
            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);
                List< IDictionary <String , object >> groupData = new List<
IDictionary < string , object >>();
                List< IList<IDictionary< String, object>>> childData = new List
< IList < IDictionary < string, object>>>();
                for ( int i = 0; i < 20; i++)
                {
                    Dictionary< String, object > curGroupMap = new Dictionary <
string , object >();
                    groupData.Add(curGroupMap);
                    curGroupMap.Add(NAME, "Group " + i);
                    curGroupMap.Add(IS_EVEN, (i % 2 == 0) ? "This group is
even" : "This group is odd");
                    List< IDictionary <String , object >> children = new List<
IDictionary < string , object >>();
                    for ( int j = 0; j < 15; j++)
                    {
                        Dictionary< String, object > curChildMap = new
Dictionary < string , object >();
                        children.Add(curChildMap);
                        curChildMap.Add(NAME, "Child " + j);
                        curChildMap.Add(IS_EVEN, (j % 2 == 0) ? "This child is
even" : "This child is odd");
                    }
                    childData.Add(children);
                }
                // Set up our adapter
                mAdapter = new SimpleExpandableListAdapter (
                        this,
                        groupData,
                        Android.Resource.Layout.SimpleExpandableListItem1,
                        new String[] { NAME, IS_EVEN },
                        new int[] { Android.Resource.Id.Text1,
Android.Resource.Id.Text2 },
                        childData,
                        Android. Resource. Layout.SimpleExpandableListItem2,
                        new String[] { NAME, IS_EVEN },
                        new int[] { Android.Resource .Id.Text1,
Android.Resource.Id.Text2 }
                        );
                SetListAdapter(mAdapter);
            }
        }
    }

Exception trace:

E/AndroidRuntime( 7498): FATAL EXCEPTION: main
E/AndroidRuntime( 7498): java.lang.RuntimeException: Unable to create
BackupAgent mono.samples.hello.LibraryActivity: java.lang.ClassCastException:
mono.samples.hello.LibraryActivity
E/AndroidRuntime( 7498):     at
android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:1891)
E/AndroidRuntime( 7498):     at
android.app.ActivityThread.access$3200(ActivityThread.java:117)
E/AndroidRuntime( 7498):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1026)
E/AndroidRuntime( 7498):     at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 7498):     at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 7498):     at
android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 7498):     at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 7498):     at
java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 7498):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 7498):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 7498):     at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 7498): Caused by: java.lang.ClassCastException:
mono.samples.hello.LibraryActivity
E/AndroidRuntime( 7498):     at
android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:1860)
E/AndroidRuntime( 7498):     ... 10 more


Reproducible: Always

Steps to Reproduce:
1.
2.
3.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list