[mono-android] Generic Activity
jcwmoore
jcwmoore at gmail.com
Thu Dec 22 19:59:14 EST 2011
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.
>
> Finally, it doesn't make sense to me, as the purpose of an Activity
> (generally) is to instantiate a single user-visible screen. By making it
> generic, you're providing a _set_ of such activities, but the UI will
> still display only one icon, so how is your app supposed to know which one
> of the set was desired?
>
> - Jon
>
Thanks for the info,
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 (minus
using a different IRepository<T>,) a generic activity makes sense to me.
Now i have managed to achieve the same results by pushing the type name into
the activity's intent, and then moving the generic parameter down to the
activities non-overridden methods.
bottom line this feature would be a neat trick to use in android and could
allow to create a very flexible, but very limited, UI. after all, this
activity is only able to display a list of strings and very little else.
--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Generic-Activity-tp5093565p5096000.html
Sent from the Mono for Android mailing list archive at Nabble.com.
More information about the Monodroid
mailing list