NumberPicker.Formatter does not seem to be invoking in Android -


i trying use numberpicker display array of strings, when try , value of current string, value integer index value of string within array default response.

i have been trying use numberpicker.formatter actual string value opposed integer index value. have implemented this, doesn't seem invoked. please tell me why , can fix it. in advance.

here code:

final numberpicker npunits = (numberpicker) numberpickerview.findviewbyid(r.id.numberpicker2);              npunits.setminvalue(1);             npunits.setdisplayedvalues(tableunitsarray);             npunits.setmaxvalue(tableunitsarray.length);             npunits.setformatter(new numberpicker.formatter()              {                 @override                 public string format(int value)                  {                     arraylist<string> stringarraylist = (arraylist<string>) arrays.aslist(tableunitsarray);                     string defaultunits = stringarraylist.get(value);                     system.out.println("value formatted result: " + defaultunits);                      return defaultunits;                 }             });             npunits.setdescendantfocusability(numberpicker.focus_block_descendants); 

numberpicker allows pick values based on min , max values specify. not need call setdisplayedvalues(). numberpicker uses string array specify set of alternate values causes formatter ignored. try removing call setdisplayedvalues().

if values numberpicker not straight forward (i.e not min max incrementing 1), can transform values in formatter desired number.


Comments