开发者

User can not interact with the Seekbar

I have one seekbar in my custom listview . Now i dont want that user change the seekba开发者_如何转开发r progress manually. so what i have to do ?

how to remove the ability for a user to interact with the SeekBar...


Try disabling the Seekbar with setEnabled(false) right after you have set the value you want to the SeekBar


ccheneson's solution works, but it also changes the color of the seekbar. if you want to leave your current bright green with the seekbar, use the following code (also found here on stackoverflow. thanks! so, just refering)

private void makeSeekbarUnchanable(ViewHolder holder) {
        holder.barRating.setOnSeekBarChangeListener( new OnSeekBarChangeListener() {

            int originalProgress;

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                //Nothing here..                
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

                originalProgress = seekBar.getProgress();
            }

            @Override
            public void onProgressChanged(SeekBar seekBar, int arg1, boolean fromUser) {
                if( fromUser == true){
                    seekBar.setProgress( originalProgress);
                }               
            }
        });
    }


setEnabled(false) works, but unfortunately change custom seekbar background for some reason.

It was a problem for me, so I used this way:

seekProgress.setOnTouchListener(new OnTouchListener()
    {
        @Override
        public boolean onTouch(View v, MotionEvent event)
        {
            return true;
        }
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜