(1) Rewrite Numberpicker has reached the modified display font color size
Public classTextcolornumberpickerextendsNumberpicker { PublicTextcolornumberpicker (Context context) {Super(context); } PublicTextcolornumberpicker (Context context, AttributeSet attrs) {Super(context, attrs); } PublicTextcolornumberpicker (context context, AttributeSet attrs,intdefstyleattr) { Super(context, attrs, defstyleattr); } @Override Public voidAddView (View child) {Super. AddView (child); Updateview (child); } @Override Public voidAddView (View Child,intindex, Android.view.ViewGroup.LayoutParams params) { Super. AddView (Child, index, params); Updateview (child); } @Override Public voidAddView (View child, Android.view.ViewGroup.LayoutParams params) {Super. AddView (Child, params); Updateview (child); } Public voidUpdateview (view view) {if(ViewinstanceofEditText) { //here to modify the properties of the display font, mainly modify the color((EditText) view). SetTextColor (Color.parsecolor ("#BAA785")); } }}
(2) To modify the split line color, you need to animate the color by reflection after the control is initialized.
Note: The following method is called after the Numberpicker setdisplayedvalues call:
1 Private voidSetnumberpickerdividercolor (Numberpicker numberpicker) {2Numberpicker Picker =Numberpicker;3field[] Pickerfields = Numberpicker.class. Getdeclaredfields ();4 for(Field pf:pickerfields) {5 if(Pf.getname (). Equals ("Mselectiondivider")) {6Pf.setaccessible (true);7 Try {8 //set color value transparency for split lines9Pf.set (Picker,NewColordrawable ( This. Getresources (). GetColor (Android. (r.color.transparent) ));Ten}Catch(IllegalArgumentException e) { One e.printstacktrace (); A}Catch(resources.notfoundexception e) { - e.printstacktrace (); -}Catch(illegalaccessexception e) { the e.printstacktrace (); - } - Break; - } + } -}
(3) Use Numberpicker Note:
1 // Disable click to open keyboard 2 picker.setdescendantfocusability (numberpicker.focus_block_descendants); 3 // set the maximum value, the minimum value has reached the display of all eligible values 4 picker.setmaxvalue (array.length-1); 5 picker.setminvalue (0);
(4) The List is converted to array[] so that Numberpicker settings setdisplayedvalues (string[]):
New string[list.size ()];list.toarray (array);
Connection: http://my.oschina.net/yaly/blog/532153
Android numberpicker control modifies split line color and font color size