How to get progress from custom SeekBar
<p>Hi I am trying to get the progress of a seekbar into a textview, I am using a custom class to make the seekbar vertical. but it crashes when I touch the seekbar.</p>

<p>with this code</p>

<pre><code>public class Slider extends Activity {
private VerticalSeekBar seekBar;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    this.seekBar = (VerticalSeekBar) this.findViewById(R.id.SeekBar01);

    final TextView tv = (TextView) findViewById(R.id.progress);

    //tv.setText(value);


    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
            //int value = seekBar.getProgress();
            tv.setText(progress);
        }
        public void onStartTrackingTouch(SeekBar seekBar) {

        }
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
}
</code></pre>

<p>}</p>

<p>heres my custom VerticalSeekBar class</p>

<pre><code>public class VerticalSeekBar extends SeekBar {

public VerticalSeekBar(Context context) {
    super(context);
}

public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public VerticalSeekBar(Context context, AttributeSet attrs) {
    super(context, attrs);
}

protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(h, w, oldh, oldw);
}

@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(heightMeasureSpec, widthMeasureSpec);
    setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}

protected void onDraw(Canvas c) {
    c.rotate(-90);
    c.translate(-getHeight(), 0);

    super.onDraw(c);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!isEnabled()) {
        return false;
    }

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_UP:
            setProgress(getMax() - (int) (getMax() * event.getY() / getHeight()));
            onSizeChanged(getWidth(), getHeight(), 0, 0);
            break;

        case MotionEvent.ACTION_CANCEL:
            break;
    }
    return true;
}
</code></pre>

<p>}</p>

<p>my xml</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
     &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
   android:layout_height="fill_parent"&gt;
  &lt;TextView  android:gravity="center"
    android:id="@+id/progress" android:layout_width="fill_parent"
    android:layout_height="wrap_content" /&gt;

  &lt;android.slider.ie.VerticalSeekBar
    android:id="@+id/SeekBar01" android:layout_width="wrap_content"
    android:layout_height="fill_parent" android:max="100"
    android:progress="0" android:secondaryProgress="25" /&gt;

    &lt;/LinearLayout&gt;
</code></pre>

<p>It would be great if you could help me, thanks.</p>
