android – 显示seekbar的上一个值

android – 显示seekbar的上一个值,第1张

概述我在数据库中存储了一些评级.无论何时移动搜索栏,那么这些评级都会显示在textview中.但问题是每当我向后移动拇指时,都不会显示向后的值.它只显示最后一个值.如何显示评级当我向后移动拇指时.我试过的代码是 – public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceStat 我在数据库中存储了一些评级.无论何时移动搜索栏,那么这些评级都会显示在textvIEw中.但问题是每当我向后移动拇指时,都不会显示向后的值.它只显示最后一个值.如何显示评级当我向后移动拇指时.我试过的代码是 –

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的上一个值所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1125196.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存