title: How to inflate a xml layout in order to implement a listener for an android seekbar?
body: <p>I have been spending hours trying to implement a seekbar listener for my android app. Everytime I start the application it crashes.
  I am trying to link the seekbar to a Threshold that can be manually changed over the seekbar. This is my layout xml file for the seekbar:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="126dp"
  android:layout_height="wrap_content"
  android:minWidth="56dp"&gt;
  
  &lt;RelativeLayout
      android:layout_width="188dp"
      android:layout_height="match_parent"&gt;
  
      &lt;SeekBar
          android:id="@+id/seekBar"
          style="@android:style/Widget.SeekBar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true"
          android:layout_toStartOf="@+id/progressBar"
          android:max="127"
          android:progress="2" /&gt;
  
      &lt;ProgressBar
          android:id="@+id/progressBar"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:layout_marginEnd="60dp"
          android:layout_alignParentTop="true"
          android:layout_alignParentEnd="true"
          android:layout_alignBottom="@+id/seekBar" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>My implementation looks as follows:</p>
  
  <pre><code> public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      getActionBar().setTitle(R.string.title_devices);
      mHandler = new Handler();
      getLayoutInflater().inflate(R.layout.actionbar_indeterminate_progress, null );
      setContentView(R.layout.actionbar_indeterminate_progress);
      final int step = 1;
      final int max = 0;
      final int min = -127;
      Threshold = (SeekBar) findViewById(R.id.seekBar);
      //Threshold.setMax( (max - min) / step );
      Threshold.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          int progressChangedValue;
          //@Override
          public void onProgressChanged(SeekBar Threshold, int progress,
                                        boolean fromUser)
          {
              // if progress = 13 -&gt; value = 3 + (13 * 0.1) = 4.3
              double value = min + (progress * step);
              progressChangedValue = (int) value;
              //progressChangedValue = progress;
          }
          //@Override
          public void onStartTrackingTouch(SeekBar Threshold) {}
  
          //@Override
          public void onStopTrackingTouch(SeekBar Threshold) {
              mThreshold = progressChangedValue;
              Toast.makeText(DeviceScanActivity.this, "Threshold has been set to: " + progressChangedValue,
                      Toast.LENGTH_SHORT).show();
          }
  
      });
  }
  </code></pre>
  
  <p>Does anyone have a hint what may cause the crash of the app? And how I could solve the problem?</p>
  
  <p>Thanks a lot!</p>
  
  <p>Sayus</p>