package org.adaptlab.chpir.android.survey.questionfragments;

import android.view.ViewGroup;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

import org.adaptlab.chpir.android.survey.QuestionFragment;

public class SliderQuestionFragment extends QuestionFragment {
    private int mProgress;
    private SeekBar mSlider;
    
    protected void beforeAddViewHook(ViewGroup questionComponent) {
        
    }

    @Override
    protected void createQuestionComponent(ViewGroup questionComponent) {
        mSlider = new SeekBar(getActivity());
        mSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mProgress = progress;
                if (mProgress > -1) {
                	setResponseText();
                }
            }

            // Required by interface
            public void onStartTrackingTouch(SeekBar seekBar) { }
            public void onStopTrackingTouch(SeekBar seekBar) { }     
        });
        beforeAddViewHook(questionComponent);
        questionComponent.addView(mSlider);
    }

    @Override
    protected String serialize() {
        return String.valueOf(mProgress);
    }

    @Override
    protected void deserialize(String responseText) {
        if (responseText.equals("")) {
        	mSlider.setProgress(-1);
        } else {
            mSlider.setProgress(Integer.parseInt(responseText));
        }
    }

    @Override
    protected void unSetResponse() {

    }
}

@@ -55,16 +55,75 @@
 ments;%0A%0A
+import android.view.MotionEvent;%0Aimport android.view.View;%0A
 import a
@@ -1132,16 +1132,335 @@
     %7D);%0A
+        mSlider.setOnTouchListener(new View.OnTouchListener()%7B%0A            @Override%0A            public boolean onTouch(View v, MotionEvent event)%7B%0A                if(mSpecialResponses!=null)%7B%0A                    mSpecialResponses.clearCheck();%0A                %7D%0A                return false;%0A            %7D%0A        %7D);%0A
         
@@ -1937,16 +1937,125 @@
 nse() %7B%0A
+        mSlider.setProgress(0);%0A        if(mResponse!=null)%7B%0A            mResponse.setResponse(%22%22);%0A        %7D
 %0A    %7D%0A%7D

Implement and test the unSetResponse function in the SliderQuestionFragmnet