On Feb 29, 2012, at 7:40 AM, Paul Johnson wrote:
> Can I enumerate the Resource.Id.textDate values, pass them into the 
> FindViewById directly?

You have full System.Reflection, so something like this (untested!) could work:

        var ids = typeof(Resources.Id);

        var tl = new List<TextView>();
        for (int i = 1; i <= 35; ++i) {
                var f = ids.GetField("textDate" + i);
                if (f == null)
                        continue;
                int value = (int) f.GetValue (null);
                tl.Add (FindViewById<TextView>(value));
        }

The only downside is that'll require Reflection, and I have no idea what the 
performance will look like in practice. It might be faster to instead do:

        foreach (int id in new[]{
                                Resources.Id.textDate1,
                                Resources.Id.textDate2,
                                Resources.Id.textDate3,
                                /* ... */ }) {
                tl.Add (FindViewById<TextView>(id));
        }

 - Jon

_______________________________________________
Monodroid mailing list
[email protected]

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

Reply via email to