Ok,
Let me explain… I want to change the background color of a selected ListView item. To do this I have a ListViewSelector.xml <?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <!--<item android:state_focused="true" android:drawable="@drawable/listview_selector_focussed" />--> <item android:state_pressed="true" android:drawable="@drawable/listview_selector_pressed" /> <item android:state_selected="true" android:drawable="@drawable/listview_selector_selected" /> <item android:drawable="@drawable/listview_selector_selected" /> </selector> At this point, if I select a ListView Item, it is marked as selected. But I have to do something when selecting a listview Item so I have to implement the OnListItemClick event. I think a listView can be implemented in two ways, one as a listActivity and two, as a listview inside a layout. This time, I use second one, and I don´t know how to invoke that event. I think there are two ways. One, with a listener and two, with a handler in getView method inside the adapter. public override View GetView(int position, View convertView, ViewGroup parent { try { //some code view.Click += delegate { calcular(view, _CT.ID_CENTRO_TRABAJO); }; return view; } catch (Exception ex) { throw ex; } } I use the second one too. When I set the line view.Click += delegate { calcular(view, _CT.ID_CENTRO_TRABAJO); }; it does not work. If I coment it, it works fine and the listViewItem background color is set using my selector. I think its because of the listViewItem state but I am not sure.. I tried to change the listViewItem state but no luck.. v.Pressed = false; v.Selected = false; NotifyDataSetChanged(); Tell me if you dont understand somethig and excuse me for my english… Thanks in advance! Un saludo Javier Martínez Sáez Responsable Soporte Técnico eLegisla <http://www.externalia.com/> Descripción: Logo_nuevo_externalia <http://www.externalia.com/> www.externalia.com Tfno.: 945 291 684 | Fax 945 205 228 sopo...@egestiona.es <http://www.egestiona.es/> Descripción: pie_egestiona_elegisla_adr www.egestiona.es <http://www.egestiona.es/> | www.elegisla.es <http://www.elegisla.es/> | www.eadr.es <http://www.eadr.es/> ******************** CLÁUSULA DE CONFIDENCIALIDAD ******************** Este mensaje electrónico y todos los ficheros adjuntos que contiene son confidenciales y destinados exclusivamente para el uso de la o las personas a las que va dirigido, pudiendo estar sujeta a Secreto Profesional. Si usted ha recibido este mensaje por error, le agradecemos lo comunique al emisor. Asimismo, le informamos que la distribución, copia o utilización de este mensaje, o de cualquier documento adjunto al mismo, cualquiera que fuera su finalidad, están prohibidas por la ley. P Antes de imprimir este e-mail piense bien si es necesario hacerlo. El medioambiente es cosa de todos De: monodroid-boun...@lists.ximian.com [mailto:monodroid-boun...@lists.ximian.com] En nombre de Doug Enviado el: lunes, 12 de noviembre de 2012 8:22 Para: Discussions related to Mono for Android Asunto: Re: [mono-android] ListView Item click color I'm not sure what the problem is from your description; try posting a full code sample showing the issue on github or something? Using lists in android isn't as trivial as it seems. You need to do something like this: https://github.com/shadowmint/monodroid-hello-cats/blob/master/HelloWorld.Android/Views/Home/NotesView.cs I'm not sure if that helps though... ~ Doug. On Mon, Nov 12, 2012 at 3:10 PM, javitxin <jav...@externalia.com> wrote: any help please! -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/ListView-Item-click-color-tp5712328p5712336.html Sent from the Mono for Android mailing list archive at Nabble.com. _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
<<image001.png>>
<<image002.gif>>
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid