title: Insert SeekBar in custom AlertDialog (Android)
body: <p>I am trying to use a SeekBar in a custom AlertDialog, but when i click the button it crashes.
  The custom AlertDialog only has a TextView with the id "seekProgress" and a SeekBar with the id "seekBar1".
  If i delete the "seekBar.setOnSeekBarChangeListener..." it doesn't crash but of course nothing happens when i move it.</p>
  
  <p>The main activity has a button with onClick="myMethod" where I make my AlertDialog. Here is the code for this method:</p>
  
  <pre><code>public void myMethod(View view){
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      LayoutInflater inflater = this.getLayoutInflater();
      builder.setView(inflater.inflate(R.layout.dialog_exchange_money_farmers, null));
      SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar1);
      seekProgress = (TextView) findViewById(R.id.seekProgress);
  
      seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          int progressValue;
          TextView seekProgress = (TextView) findViewById(R.id.seekProgress);
  
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
              progressValue = progress;
              seekProgress.setText("Covered: " + progress + " / " + seekBar.getMax());
          }
  
          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
  
          }
  
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
              seekProgress.setText("Covered: " + progressValue + " / " + seekBar.getMax());
          }
      });
  
      AlertDialog alertDialog = builder.create();
      alertDialog.show();
  }
  </code></pre>
  
  <p>How can I make the SeekBar Listener to work?</p>
  
  <p>EDIT: When i debug i get this error:
  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.SeekBar.setOnSeekBarChangeListener(android.widget.SeekBar$OnSeekBarChangeListener)' on a null object reference</p>
  
  <p>I have <code>SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar1);</code> why does it say it is null?</p>
  
  <p>SOLUTION:
  I had to tell him in which layout were the items.</p>
  
  <pre><code>     View testView = inflater.inflate(R.layout.dialog_exchange_money_farmers, null);
          builder.setView(testView);
          seekBar = (SeekBar) testView.findViewById(R.id.seekBar1);
          seekProgress = (TextView) testView.findViewById(R.id.seekProgress);
  </code></pre>