You can also always unsubscribe then subscribe... as unsubscribe will do
nothing if its not yet registered

Le 28 oct. 2011 20:47, "Jonathan Pryor" <j...@xamarin.com> a écrit :

> On Oct 27, 2011, at 12:01 PM, bmellac wrote:
> > I have buttons in ListViewItems, so in my Adapter.GetView(...), I have to
> > wire eventhandler for the .Click methods of my buttons :
> > convertView.FindViewById<Button>(Resource.Id.art_qte_minus).Click += new
> > EventHandler(art_qte_minus_Click);
> ...
> > So how can I check if there is an already attached eventhandler ?
>
> Short answer: you don't.
>
> Slightly longer answer: where is your convertView coming from? :-)
>
> Normally you're using LayoutInflator.Inflate() to create a new View, so
> only register the event when you create:
>
>        public override View GetView (int position, View convertView,
> ViewGroup parent)
>        {
>                if (convertView == null) {
>                        var inflator = (LayoutInflater)
> Context.GetSystemService (Context.LayoutInflaterService);
>                        convertView = inflator.Inflate (resourceId, null);
>
>  convertView.FindViewById<Button>(Resource.Id.art_qte_minus).Click +=
> art_qte_minus_Click;
>                }
>                // ...
>        }
>
> > By the way, I'd like to use a ViewHolder to be clean, but I can't find
> the
> > corresponding class in c#.
>
> I'm not sure what type you're referring to. A web search for "ViewHolder
> site:android.com" finds:
>
>
> http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html
>
> in which ViewHolder is:
>
>        static class ViewHolder {
>                TextView text;
>                ImageView icon;
>        }
>
> so this appears to be a design pattern rather than a concrete type, and the
> C# equivalent would be:
>
>        class ViewHolder : Java.Lang.Object {
>                public TextView Text {get; set;}
>                public ImageView Icon {get; set; }
>        }
>
>  - Jon
>
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

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

Reply via email to