pioneerBhawna pioneerBhawna - 6 months ago 55
Android Question

How to change progress of the circular seekbar in Android?

How to change progress in the circular seek bar when I enter number in edittext and click on button?

Below is the snapshot of what I am trying to do

enter image description here

Answer

I got the answer of my question. If you want to show circular seekbar like mine in the above layout and want to send value which is coming from server use this code:

https://github.com/RaghavSood/AndroidCircularSeekBar

Change its layout according to your requirements in CircularSeekBar class

If you want to send value for its progress programatically. Then, replace setProgress() with the below method:

public void setProgress(int progress) //this is an Android function

    { 
        if (this.progress != progress) 
        { 
            this.progress = progress; 
            if (!CALLED_FROM_ANGLE) 
            { 
                int newPercent =this.progress; 
                int newAngle = (newPercent * 360)/100; 
                this.setAngle(newAngle); 
                this.setProgressPercent(newPercent); 
            } 
            mListener.onProgressChange(this, this.getProgress()); 
            CALLED_FROM_ANGLE = false; 
        } 
    } 

Now, in activity where you are using this Circular Seek bar , set its progress using SetProgress() method . Like this:-

com.exp.CustomControls.CircularSeekBar dynamicSeekBar=(com.exp.CustomControls.CircularSeekBar)findViewById(R.id.img_score_rovr);
dynamicSeekBar.setMaxProgress(100);

dynamicSeekBar.setProgress(progress_score); // Here, you can send any value

dynamicSeekBar.invalidate();

All the best....

If you get any problem , let me know.......I have got expertise in it

Comments