I save some ratings in the database. Each time you move the browser, these ratings are displayed in text form. But the problem is that whenever I returned the thumb, the return values are not displayed. It shows only the last value. How can I show grades when I move my thumb in the opposite direction. The code I tried is
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
{
view = inflater.inflate(R.layout.interval, container, false);
seekbar=(SeekBar)view.findViewById(R.id.seekBar1);
ques = (TextView)view. findViewById(R.id.question);
textrating=(TextView)view.findViewById(R.id.textRating);
db=new DatabaseHandler(getActivity());
retrieveQuestion();
retrieveRating();
seekbar.setProgress(0);
seekbar.incrementProgressBy(diff);
seekbar.setMax(ratinglast);
seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
{
@Override
public void onProgressChanged(SeekBar seekbar, int progress, boolean fromuser)
{
Log.e("DEBUG", "Progress is: "+progress);
if(j<len)
{
progress=rating[j];
j++;
textrating.setText(""+progress);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekbar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekbar)
{
}
});
return view;
}
void retrieveQuestion()
{
db.open();
Cursor c=db.getQuestion(username,surveyName,selectedQues,question_no);
if(c.moveToFirst())
{
int index=c.getColumnIndex("question");
question1= c.getString(index);
ques.setText(question1);
}
}
public void retrieveRating()
{
Cursor c=db.getAnswer(username, surveyName, selectedQues, question_no);
len=c.getCount();
Log.e("len",""+len);
if(c.moveToFirst())
{
do
{
int index=c.getColumnIndex("answer");
rating[i]=c.getInt(index);
Log.e("i",""+i);
Log.e("rating in do while",""+rating[i]);
i++;
}while(c.moveToNext());
}
rating1=rating[0];
rating2=rating[1];
diff=rating2-rating1;
Log.e("diff",""+diff);
ratinglast=rating[len-1];
Log.e("ratinglast",""+ratinglast);
}
}
source
share