I am trying to configure the NumberPicker
widget using API 14. There are very little tutorials or instructions online that would help me set it up properly.
so far I have the following code implemented in main.xml:
<NumberPicker
android:id="@+id/numberPicker1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal" />
and in the main activity in the onCreate() method:
NumberPicker np = (NumberPicker) findViewById(R.id.numberPicker1);
String[] nums = new String[20];
for(int i=0; i<nums.length; i++)
nums[i] = Integer.toString(i);
np.setMinValue(1);
np.setMaxValue(20);
np.setWrapSelectorWheel(false);
np.setDisplayedValues(nums);
np.setValue(1);
When running my application in the emulator the numberpicker widget does not get displayed as expected. The button's are not left and right but up and down. And the values overlay each other instead of one number being displayed. Clicking an arrow crashes the application.
EDIT
Made changes as described below in first answer however the numberpciker is not usable, please see screenshot:
Any help would be appreciated.