2

edittext に数値を入力してボタンをクリックすると、循環シーク バーの進行状況を変更するにはどうすればよいですか?

以下は、私がやろうとしていることのスナップショットです

ここに画像の説明を入力

4

4 に答える 4

2

http://devadvance.com/circularseekbar/

別のアプリ用にまったく新しい CircularSeekBar を開発し、オープン ソースにすることにしました。RaghavSood によるものは適切に機能しますが、カスタマイズ可能ではなく、正しく機能する setProgress/getProgress メソッドがありません。

これがまったく役立つかどうか教えてください。

編集: レイアウトで TextView を使用する場合のコールバック:

public class CircleSeekBarListener implements OnCircularSeekBarChangeListener {
    @Override
    public void onProgressChanged(CircularSeekBar seekBar, int progress, boolean fromUser) {
        // Put your code here
        TextView text = (TextView)findViewById(R.id.TextView1);

        text.setText("" + progress);
    }
}
于 2013-09-30T12:57:39.680 に答える
1

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

于 2013-05-29T10:01:47.700 に答える
0

この簡単なコードを試して、円形の進行状況バーを作成できます。

private void circularImageBar(ImageView iv2, int i) {

    Bitmap b = Bitmap.createBitmap(300, 300,Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(b); 
    Paint paint = new Paint();

        paint.setColor(Color.parseColor("#c4c4c4"));
        paint.setStrokeWidth(10);
        paint.setStyle(Paint.Style.STROKE);
        canvas.drawCircle(150, 150, 140, paint);
        paint.setColor(Color.parseColor("#FFDB4C"));
        paint.setStrokeWidth(10);   
        paint.setStyle(Paint.Style.FILL);
        final RectF oval = new RectF();
        paint.setStyle(Paint.Style.STROKE);
        oval.set(10,10,290,290);
        canvas.drawArc(oval, 270, ((i*360)/100), false, paint);
        paint.setStrokeWidth(0);    
        paint.setTextAlign(Align.CENTER);
        paint.setColor(Color.parseColor("#8E8E93")); 
        paint.setTextSize(140);
        canvas.drawText(""+i, 150, 150+(paint.getTextSize()/3), paint); 
        iv2.setImageBitmap(b);
}
于 2014-10-30T12:55:56.823 に答える