I was under the impression that this should be sufficient to style the elements; at least that's how I read http://developer.android.com/guide/appendix/faq/commontasks.html#selectingtext. But neither the emulator nor an actual device show any styles; is there something else that needs to be done?
Usually, I would extend an appropriate Adapter class(e.g.: BaseAdapter) and override all its methods to cater to my needs. I would've put the following code inside getView() method of my adapter, which is called by the framework once for every row to be drawn, and applied these styles conditionally there.
Ulf Dittmer wrote:That worked like a charm with just a few minor tweaks. Kinda cool that it's possible to style each row of the list individually. Not that one would (or should) do that, but it's nice to know that it's possible :-)
Thanks very much!
Glad to know that I could be of any help.
If you are working with ListView, I would suggest going through the video of Romain Guy's "Turbo Charge your UI" talk he delivered during Google I/O conference in May2009.
It is available on YouTube and is about an hour long but worth the time.
There is still one more optimization you can apply here using the ViewHolder pattern. This would reduce the findViewById(..) calls which are considered expensive too.(Note that this would affect the performance had the layout of your row been a little more "dense" or complex and also if the number of rows in the list were high).
Here is the pattern: