0

I have a spinner with items, populated via ArrayAdapter. I want to change font style for some (not for all) of spinner items, both for spinner's combobox and listbox. I guess that I need to subclass something, but I don't understand what. How can I do that?

Thanks!

lstipakov
  • 3,138
  • 5
  • 31
  • 46

2 Answers2

10

Ok I got it.

  1. Subclass ArrayAdapter and override getView and getDropDownView.
  2. In those methods, call super.getView or super.getDropDownView and save returned value.
  3. Set Typeface for view returned at (2) (thx Sameer Segal).
lstipakov
  • 3,138
  • 5
  • 31
  • 46
1

You need to apply fonts (typeface) to the TextViews of the layouts. Extract them through R.id.* or by supplying your own custom layout

Sameer Segal
  • 21,813
  • 7
  • 42
  • 56
  • You mean I have to create my own layout instead of using simple_spinner_item and simple_spinner_dropdown_item? But how can I do that for specific spinner items? E. g. I am doing _adTo.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); so if I will change it to my_italic_layout, every item will be italic. – lstipakov Oct 10 '10 at 17:11
  • If you are wondering about how to do it for the specific spinner items, Do this: Check the incoming position parameter in the getView() and use it to target specific spinner items. – Syed Danish Ali Nov 11 '15 at 06:26