[mono-android] [Monodroid] SetTag and the Java.Lang.Object

Tom Opgenorth tom at opgenorth.net
Mon Mar 14 22:55:33 EDT 2011


Hmmm, re-reading the bug, maybe what I'm doing is not supported (but it's
easy to work around).  But, here is what I'm trying do:  I have a class
called BuildingRowWrapper.  Basically, it's a helper that caches things like
TextView references and handles the logic for displaying information in a
row of a ListActivity.  I have a ArrayAdapter.  Inside my ArrayAdapter I do
this :

        public override View GetView(int position, View convertView,
ViewGroup parent)
        {
            BuildingRowWrapper rowWrapper;

            if (convertView == null)
            {
                convertView =
_context.LayoutInflater.Inflate(Resource.Layout.historicalbuildingrow,
null);
                rowWrapper = new BuildingRowWrapper(convertView);
                convertView.Tag = rowWrapper;
            }
            else
            {
                rowWrapper = (BuildingRowWrapper) convertView.Tag;
            }

            if (_buildingLocations.Any())
            {
                rowWrapper.Display(_buildingLocations[position]);
            }

            return convertView;
        }

Now, if BuildingRowWrapper inherits from Java.Lang.Object, then no problem
(which is what I did).   I'd expect that I'd be able to assign any object to
View.Tag, not just .NET primitives and Java.Lang.Object subclases.



On Mon, Mar 14, 2011 at 15:00, Jonathan Pryor <jpryor at novell.com> wrote:
> On Mar 13, 2011, at 12:36 PM, Tom Opgenorth wrote:
>> Just came across this same behavior in P14.  Bug report says it's
>> closed, could this be a regression?
>
> Could you elaborate on the behavior you're seeing? #635129 says that we'll
add implicit conversion operators from several builtin types (int, string,
etc.) to Java.Lang.Object, thus allowing the following to compile w/o
error::
>
>        button.Tag = "2";
>
> This is still the case (that is, it compiles and executes properly for
me), so I'm at a loss to deduce the bug you're reporting.
>
>  - Jon
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>



-- 
http://www.opgenorth.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110314/70a8345c/attachment.html 


More information about the Monodroid mailing list