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); /*l1=(linearLayout)vIEw.findVIEwByID(R.ID.linear);*/ 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) { // Todo auto-generated method stub } @OverrIDe public voID onStopTrackingtouch(Seekbar seekbar) { // Todo auto-generated method stub } }); 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,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); }}解决方法 我找到了一个替代解决方案来解决我的问题 –
我实现的代码是:
public VIEw onCreateVIEw(LayoutInflater inflater,Bundle savedInstanceState) { vIEw = inflater.inflate(R.layout.interval,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); //ratinglast is last rating seekbar.setMax(ratinglast); seekbar.setonSeekbarchangelistener(new OnSeekbarchangelistener() { @OverrIDe public voID onProgressChanged(Seekbar seekbar,boolean fromuser) { Log.e("DEBUG","Progress is: "+progress); //diff is difference between two ratings. progress = ((int)Math.round(progress/diff ))*diff; seekbar.setProgress(progress); textrating.setText(progress + ""); } @OverrIDe public voID onStartTrackingtouch(Seekbar seekbar) { // Todo auto-generated method stub } @OverrIDe public voID onStopTrackingtouch(Seekbar seekbar) { } }); return vIEw; } //Method to retrIEve rating from sqlite database public voID retrIEverating() { Cursor c=db.getAnswer(username,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); }总结
以上是内存溢出为你收集整理的android – 显示seekbar的上一个值全部内容,希望文章能够帮你解决android – 显示seekbar的上一个值所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)