How to change font style for spinner item

2019-01-19 09:05发布

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!

2条回答
三岁会撩人
2楼-- · 2019-01-19 09:46

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

查看更多
ゆ 、 Hurt°
3楼-- · 2019-01-19 09:53

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).
查看更多
登录 后发表回答