title: Android Number Picker get value to textview
body: <p>I am using an alert dialog with a number picker, but I don't know a easy way to get te number picker value to an textview in the activity when I press the OK button of the alert.</p>
  
  <p>Activity java code:</p>
  
  <pre><code>public class SecondActivity extends Activity {
  
  public void button2 (View v){
  
      View v1 = getLayoutInflater().inflate(R.layout.dialog1, null);
  
      NumberPicker picker = (NumberPicker) v1.findViewById(R.id.np1);
      picker.setMinValue(1);
      picker.setMaxValue(20);
      picker.setWrapSelectorWheel(false);
      //final int number = picker.getValue();
  
      AlertDialog.Builder builder =  new AlertDialog.Builder(this);
      builder.setView (v1);
      builder.setTitle("Cantidad");
      builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
              return;
          } });
      builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
              return;
          } }); 
  
      AlertDialog dialog = builder.create();
      dialog.show();
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_second);
  
  }
  
  }
  </code></pre>
  
  <p>Display Layout:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"&gt;
  
  
    &lt;NumberPicker
        android:id="@+id/np1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
         /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Activity Layout:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="ale.demarco.ale005.SecondActivity$PlaceholderFragment" &gt;
  
   &lt;TextView
      android:id="@+id/Text2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/Text2" 
      android:textSize="20sp"/&gt;
  
  
  
  &lt;Button
      android:id="@+id/button2"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="@string/button2"
      android:onClick="button2"
      android:layout_gravity="right" /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>