How to change font style for spinner item

情到浓时终转凉″ 提交于 2019-12-17 19:56:31

问题


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!


回答1:


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).



回答2:


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



来源:https://stackoverflow.com/questions/3901231/how-to-change-font-style-for-spinner-item

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!