On Aug 14, 2012, at 6:15 AM, Goncalo Oliveira <[email protected]> wrote:
> The thing is... this is kind of unusable. The whole reason I'm using
> reflection is because I don't know which properties I might need.
I don't understand this; why is Reflection preferable to using type checking?
Why wouldn't you know which properties you need?
static int GetSelectedItemPosition (object value)
{
var v = value as AdapterView; // base class of Spinner
if (s != null)
return v.SelectedItemPosition;
var a = value as ListActivity;
if (a != null)
return a.SelectedItemPosition;
#if __ANDROID_11__
var w = value as ListPopupWindow;
if (w != null)
return w.SelectedItemPosition;
var f = value as ListFragment;
if (f != null)
return f.SelectedItemPosition;
#endif // __ANDROID_11__
// check other types as necessary
throw new NotSupportedException ("Cannot get
SelectedItemPosition from " + value.GetType ().FullName);
}
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid