title: android, NumberPicker Out of bounds
body: <pre><code>NumberPicker serviceWheel = (NumberPicker) findViewById(R.id.serviceSelector);
  serviceWheel.setMaxValue(serviceArray.length());
  String[] profiles = new String[serviceArray.length()];
  for (int i = 0; i &lt; serviceArray.length(); i++){
     JSONObject profileObject = serviceArray.getJSONObject(i);
     profiles[i] = profileObject.getString("description");
  }
  serviceWheel.setDisplayedValues(profiles);
  serviceWheel.setWrapSelectorWheel(false);
  </code></pre>
  
  <p><br></p>
  
  <pre><code> E/AndroidRuntime﹕ FATAL EXCEPTION: main
      java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
              at android.widget.NumberPicker.ensureCachedScrollSelectorValue(NumberPicker.java:1756)
              at android.widget.NumberPicker.incrementSelectorIndices(NumberPicker.java:1722)
              at android.widget.NumberPicker.scrollBy(NumberPicker.java:1097)
              at android.widget.NumberPicker.onTouchEvent(NumberPicker.java:880)
              at android.view.View.dispatchTouchEvent(View.java:7565)
  </code></pre>
  
  <p><code>serviceArray</code> is a <code>JSONArray</code>, with a length of <code>3</code>. I tried to add padding when instatiating the array ( <code>serviceArray.length() + 1</code> ) but this caused failure before the activity was shown. The NumberPicker displays fine but when i scroll to the last entry of the array, it crashes with this error. There is no reference to code line in my code</p>