Set the selector xml to the item layout and not the listView. That should work. Your approach should also work. Can you post a screenshot of how it looks now?
On Wed, Oct 20, 2010 at 12:29 PM, Hendrik Greving <[email protected]>wrote: > If I don't set drawSelectorOnTop, it does nothing. I've also tried > getting the TextView and call tv.bringToFront(); within onItemClick of the > AdapterView.OnItemClickListener. This doesn't do anything, too. Maybe it's > called before the selection drawable is drawn :/ What's the standard way to > do this? > > ----- Original Message ----- > *From:* Kumar Bibek <[email protected]> > *To:* [email protected] > *Sent:* Tuesday, October 19, 2010 11:51 PM > *Subject:* Re: [android-developers] Re: ListView setOnTouchListener > > drawSelector on top, don't set it and try > > On Wed, Oct 20, 2010 at 12:13 PM, Hendrik Greving > <[email protected]>wrote: > >> Ok >> >> lv.setDrawSelectorOnTop(true); >> lv.setSelector(R.drawable.list_selected); >> >> does draw a drawable, but it wipes out the rest. I would only like to -of >> course - the background of the View which was the list item inthe unselected >> state. How would you do this? >> >> ----- Original Message ----- From: "Hendrik Greving" < >> [email protected]> >> To: <[email protected]> >> Sent: Tuesday, October 19, 2010 11:21 PM >> Subject: Re: [android-developers] Re: ListView setOnTouchListener >> >> >> >> Hmm. I tried ListView... >>> lv.setOnItemSelectedListener(AdapterView.OnItemSelectedListener() .... >>> >>> It seems the callback isn't even called for my ListView. I've also >>> experimented with <selection> .xml file and setting this as a background for >>> a View to bind to the SimpleCursorAdapter. I don't know if this is supposed >>> to work either. I thought the first way (setOnItemSelectedListener) is >>> supposed to work, actually.. >>> >>> >>> ----- Original Message ----- From: "Kumar Bibek" <[email protected]> >>> To: "Android Developers" <[email protected]> >>> Sent: Tuesday, October 19, 2010 11:16 PM >>> Subject: [android-developers] Re: ListView setOnTouchListener >>> >>> >>> You should use the selectors for a list item and whenever you want to >>> set a selection, call the listview's method for that. Doing it on >>> touch, has a few bad effects, which are difficult to handle, or >>> atleast you would need a few lines of code to handle specific >>> gestures. >>> >>> On Oct 20, 10:41 am, "Hendrik Greving" <[email protected]> wrote: >>> >>>> I have a ListView and a database cursor which I set with setListAdapter. >>>> The >>>> adapter is a SimpleCursorAdapter which takes a xml description for the >>>> ListView items. How can I set a onTouch handler for every item, in order >>>> to >>>> highlight when it's being touched? >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To post to this group, send email to [email protected] >>> To unsubscribe from this group, send email to >>> [email protected]<android-developers%[email protected]> >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >>> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected]<android-developers%[email protected]> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > > > -- > Kumar Bibek > http://techdroid.kbeanie.com > http://www.kbeanie.com > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

