On Dec 22, 2011, at 7:59 PM, jcwmoore wrote:
> Jonathan Pryor-2 wrote
>> 
>> StartActivity(typeof(LookupActivity<AmpachePlaylist>));
>> 
>> This won't work, because an Android Callable Wrapper will be generated for
>> LookupActivity<T> (as LookupActivity_1), but not for
>> LookupActivity<AmpachePlaylist>. Thus, when Android attempts to create a
>> LookupActivity_1, we'll attempt to run the managed side constructor, which
>> will fail as 'T' is unknown (and not knowable).
>> 
>> I'm not even sure if it's possible to make it work, either.

In this case, I meant I wasn't sure how to make a generic "leaf" class work, 
with [Activity] on the generic type.

> Generally, i would agree with you that it doesn't make sense to have a
> generic activity; however, in this case the activity is very simple, it just
> displays a list of names, playlist names, artist names or album names, with
> no special logic, just a list of strings.  In this case, sense i don't want
> to write 3 activities that would literally be the exact same code

I did not mean to imply that it didn't make sense to have a generic type within 
the inheritance hierarchy. :-)

Thus, I would expect the following to work:

        class LookupActivity<T> : Activity {
                /* ... */
        }

        [Activity]
        class AmpachePlaylistActivity : LookupActivity<AmpachePlaylist> {
        }

        ...
        StartActivity (typeof (AmpachePlaylistActivity));

That will result in AndroidManifest.xml listing only non-generic types, which 
makes perfect sense, and I believe that this should work.

 - Jon

_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

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

Reply via email to