I need to create two NumberPicker, one with 5000 elements, and the other one with 20000 elements. I set up this two pickers at startup of my app (inside splashscreen activity), but generation requires a lot of time (more or less 10/15 seconds). There's a way to optimize this process and reduce generation time?
this is how i initialize pickers:
picker = new NumberPicker(context);
picker.setLayoutParams(
new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
pickerValues = new String[20000];
for (int i = 0; i < pickerValues.length; i++)
pickerValues[i] = i;
picker.setMinValue(1);
picker.setMaxValue(20000);
picker.setWrapSelectorWheel(false);
picker.setDisplayedValues(pickerValues);
picker.setValue(1);
picker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
then i change color of picker (it's showed into a Custom dialog)
final int count = picker.getChildCount();
for (int i = 0; i < count; i++) {
View child = picker.getChildAt(i);
if (child instanceof EditText) {
try {
Field selectorWheelPaintField = picker.getClass()
.getDeclaredField("mSelectorWheelPaint");
selectorWheelPaintField.setAccessible(true);
((Paint) selectorWheelPaintField.get(picker))
.setColor(MyApp.getContext().getResources().getColor(R.color.blue));
((EditText) child).setTextColor(MyApp.getContext().getResources().getColor(R.color.blue));
picker.invalidate();
} catch (NoSuchFieldException e) {
} catch (IllegalAccessException e) {
} catch (IllegalArgumentException e) {
}
}
}