android - Change the text color of NumberPicker -


i've looked @ of threads on , none provided answer works. styling numberpicker not work (as per thread: numberpicker textcolour)

setting style attribute on numberpicker style has color item not have effect either. nor setting textcolor attribute on numberpicker xml anything.

closest i've got using numberpicker cast getchildat() edittext , setcolor() on edittext, changes color of child once upon initialization , every time selected thereon; not looking either.

any help? thanks

this code should solve problem. problem experiencing because during construction of numberpicker captures edittext textcolor , assigns to paint can draw numbers above , below edit text same color.

import java.lang.reflect.field;  public static boolean setnumberpickertextcolor(numberpicker numberpicker, int color) {     final int count = numberpicker.getchildcount();     for(int = 0; < count; i++){         view child = numberpicker.getchildat(i);         if(child instanceof edittext){             try{                 field selectorwheelpaintfield = numberpicker.getclass()                     .getdeclaredfield("mselectorwheelpaint");                 selectorwheelpaintfield.setaccessible(true);                 ((paint)selectorwheelpaintfield.get(numberpicker)).setcolor(color);                 ((edittext)child).settextcolor(color);                 numberpicker.invalidate();                 return true;             }             catch(nosuchfieldexception e){                 log.w("setnumberpickertextcolor", e);             }             catch(illegalaccessexception e){                 log.w("setnumberpickertextcolor", e);             }             catch(illegalargumentexception e){                 log.w("setnumberpickertextcolor", e);             }         }     }     return false; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -