tags:

views:

131

answers:

2

Is there anyway to set a custom font or color for the selected item in a Spinner? For example, I open the spinner and click a priority of "High". I'm my layout containing the spinner, I would like to see the word "High" in red or a custom font.

I can't seem to obtain the textview to make the necessary change. I always obtain a NullPointerException if I typecast the spinner.getSelectedView() to textview and attempt to set the color. any ideas? thanks in advance!

A: 

You are the one who tells Android the "font or color for the selected item in a Spinner". This comes from the layout resource you pass into the SpinnerAdapter you give to the Spinner. If you do not like the layout you are presently using, change the layout. If you are using a layout provided by Android, copy it from your SDK ($ANDROID_HOME/platforms/$VERSION/data/res/) into your project, change it, then refer to your local layout rather than the system-supplied one.

CommonsWare
A: 

hmm I can't seem to reply to to your post. I shouldve created an account first before I posted this question. Well, I can probably change the adapter to use a different layout resource, but that seems a bit cumbersome. There isn't a way to dynamically set it in the code? Like I said, I tried to setTypeface for the textview in my customlayout, but I just get a null pointer exception.

AndrewC