1

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...

Chirag
  • 56,621
  • 29
  • 151
  • 198

3 Answers3

3

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

ccheneson
  • 49,072
  • 8
  • 63
  • 68
  • if i set enabled false then is it visible or not ? – Chirag Apr 07 '11 at 11:56
  • Yes, it should be visible. `setVisibility` should be used if you want to make it visible or invisible (gone). `setEnabled` should not allow the user to interact with the SeekBar – ccheneson Apr 07 '11 at 12:16
2

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;
        }
    });
stkent
  • 19,772
  • 14
  • 85
  • 111
mc.dev
  • 2,675
  • 3
  • 21
  • 27
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);
                }               
            }
        });
    }
Community
  • 1
  • 1
cV2
  • 5,229
  • 3
  • 43
  • 53