android - Change font of one part of the element of string array for Spinner? -


i trying change font 1 part of string of string array can't work. trying implement below:

typeface font = typeface.createfromasset(getassets(), "fonts/greek.ttf");  spannablestringbuilder ss1 = new spannablestringbuilder("ws="); ss1.setspan (new customtypefacespan("", font), 0, 1, spanned.span_exclusive_inclusive);  arrayspinner = new string[] {"s ", "ms", ss1.tostring()}; s = (spinner) findviewbyid(r.id.spinner2); arrayadapter<string> adapter2 = new arrayadapter<>(getapplicationcontext(), android.r.layout.simple_spinner_item, arrayspinner); adapter2.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); s.setadapter(adapter2); 

so "ws=" have w converted corresponding greek font symbol, , s= stay in default font.

if try insert ss1.tostring() in arrayspinner seems lose typeface characteristics when set .tostring(). there way?

make change in adapter set font in side adapter

arrayadapter<string> adapter = new arrayadapter<string>(this,                      r.layout.spinaca, items) {             public view getview(int position, view convertview, viewgroup parent) {                   view v = super.getview(position, convertview, parent);                     typeface externalfont=typeface.createfromasset(getassets(), "fonts/helveticaneueltcom-lt.ttf");                   ((textview) v).settypeface(externalfont);                     return v;           }               public view getdropdownview(int position,  view convertview,  viewgroup parent) {                    view v =super.getdropdownview(position, convertview, parent);                     typeface externalfont=typeface.createfromasset(getassets(), "fonts/helveticaneueltcom-lt.ttf");                   ((textview) v).settypeface(externalfont);                   v.setbackgroundcolor(color.green);                     return v;           }   };           adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);                                        spinner.setadapter(adapter);

note if need clear picture please refer http://hukum-android-lab.blogspot.in/2013/06/android-how-to-change-spinner-items.html


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -