User can not interact with the Seekbar

元气小坏坏 提交于 2019-12-08 04:43:31

问题


I have one seekbar in my custom listview . Now i dont want that user change the seekbar progress manually. so what i have to do ?

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


回答1:


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




回答2:


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);
                }               
            }
        });
    }



回答3:


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;
        }
    });


来源:https://stackoverflow.com/questions/5580554/user-can-not-interact-with-the-seekbar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!