title: How to use NumberPicker widget Android 4.0
body: <p>I am trying to configure the <code>NumberPicker</code> widget using <strong>API 14</strong>. There are very little tutorials or instructions online that would help me set it up properly. </p>
  
  <p>so far I have the following code implemented in <em>main.xml</em>: </p>
  
  <pre><code>&lt;NumberPicker
      android:id="@+id/numberPicker1"
      android:layout_width="match_parent"
      android:layout_height="48dp"
      android:orientation="horizontal" /&gt;
  </code></pre>
  
  <p>and in the main activity in the onCreate() method: </p>
  
  <pre><code>NumberPicker np = (NumberPicker) findViewById(R.id.numberPicker1);
      String[] nums = new String[20];
      for(int i=0; i&lt;nums.length; i++)
             nums[i] = Integer.toString(i);
  
      np.setMinValue(1);
      np.setMaxValue(20);
      np.setWrapSelectorWheel(false);
      np.setDisplayedValues(nums);
      np.setValue(1);
  </code></pre>
  
  <p>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. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Made changes as described below in first answer however the numberpciker is not usable, please see screenshot: </p>
  
  <p><img src="https://i.stack.imgur.com/5jOSd.jpg" alt="Numberpicker screenshot"></p>
  
  <p>Any help would be appreciated. </p>