android CircularSeekBar

Android 中的 seekBar会被开发者经常用到,用的最多的空拍是控制音量。但是有时后为了更好的UI效果,横着的拖动条不能满足我们项目的需要,我们可能需要竖直的或者圆形的拖动条,那这两种样式的类SeekBar的效果如何实现呢,接下来小编会一一给出效果和源码。接下来,先说一说圆形的效果吧,有图有真相,请看图:

       

看过图之后是不是觉得很炫,自己赞一个,下面给出源码:

 

/values/attr.xml:  

 

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.   
  4.     <declare-styleable name="HoloCircleSeekBar">  
  5.         <attr name="wheel_size" format="integer" />  
  6.         <attr name="pointer_size" format="integer" />  
  7.         <attr name="max" format="integer"></attr>  
  8.         <attr name="show_text" format="boolean"></attr>  
  9.         <attr name="start_angle" format="integer"></attr>  
  10.         <attr name="end_angle" format="integer"></attr>  
  11.         <attr name="text_size" format="integer"></attr>  
  12.         <attr name="init_position" format="integer"></attr>  
  13.         <attr name="color" format="string"></attr>  
  14.         <attr name="wheel_active_color" format="string"></attr>  
  15.         <attr name="wheel_unactive_color" format="string"></attr>  
  16.         <attr name="pointer_color" format="string"></attr>  
  17.         <attr name="pointer_halo_color" format="string"></attr>  
  18.         <attr name="text_color" format="string"></attr>  
  19.     </declare-styleable>  
  20.   
  21. </resources>  


ZJBCircleSeekBar.java:

 

 

  1. package com.example.circleseekbar;  
  2.   
  3. import android.content.Context;  
  4. import android.content.res.TypedArray;  
  5. import android.graphics.Bitmap;  
  6. import android.graphics.BitmapFactory;  
  7. import android.graphics.Canvas;  
  8. import android.graphics.Color;  
  9. import android.graphics.Paint;  
  10. import android.graphics.Rect;  
  11. import android.graphics.RectF;  
  12. import android.graphics.SweepGradient;  
  13. import android.os.Bundle;  
  14. import android.os.Parcelable;  
  15. import android.util.AttributeSet;  
  16. import android.view.MotionEvent;  
  17. import android.view.View;  
  18.   
  19. /** 
  20.  * @author zjbpku 
  21.  * @time 2013-08-21 
  22.  * @blog http://blog.csdn.net/zjbpku 
  23.  */  
  24.   
  25. public class ZJBCircleSeekBar extends View {  
  26.     /** 
  27.      * 保存状态 
  28.      */  
  29.     private static final String STATE_PARENT = "parent";  
  30.     private static final String STATE_ANGLE = "angle";  
  31.   
  32.     /*** 
  33.      * 事件监听 
  34.      */  
  35.     private OnCircleSeekBarChangeListener mOnCircleSeekBarChangeListener;  
  36.   
  37.     /** 
  38.      * 圆环paint对象 
  39.      */  
  40.     private Paint mColorWheelPaint;  
  41.   
  42.     /** 
  43.      * 游标paint对象 
  44.      */  
  45.     private Paint mPointerHaloPaint;  
  46.   
  47.     /** 
  48.      * 游标为图画时的paint对象 
  49.      */  
  50.     private Paint mPointerColor;  
  51.   
  52.     /** 
  53.      * 圆环的宽度 
  54.      */  
  55.     private final int mColorWheelStrokeWidth = 10;  
  56.   
  57.     /** 
  58.      * 游标所在圆环半径 
  59.      */  
  60.     private final int mPointerRadius = 80;  
  61.   
  62.     /** 
  63.      * The rectangle enclosing the color wheel. 
  64.      */  
  65.     private RectF mColorWheelRectangle = new RectF();  
  66.   
  67.     /** 
  68.      * {@code true} 点击游标 {@code false} 停止 
  69.      *  
  70.      * @see #onTouchEvent(MotionEvent) 
  71.      */  
  72.     private boolean mUserIsMovingPointer = false;  
  73.   
  74.     /** 
  75.      *  
  76.      */  
  77.     private float mTranslationOffset;  
  78.   
  79.     /** 
  80.      * 圆环半径 Note: (Re)在onMeasure计算{@link #onMeasure(int, int)} 
  81.      */  
  82.     private float mColorWheelRadius;  
  83.   
  84.     private float mAngle;  
  85.     private String text;  
  86.     private int conversion = 0;  
  87.     private int max = 100;  
  88.     private String color_attr;  
  89.     private SweepGradient s;  
  90.     private Paint mArcColor;  
  91.     private String wheel_color_attr, wheel_unactive_color_attr,  
  92.             pointer_color_attr, pointer_halo_color_attr;  
  93.     private int init_position;  
  94.     private boolean block_end = false;  
  95.     private float lastX;  
  96.     private int last_radians = 0;  
  97.     private boolean block_start = false;  
  98.   
  99.     private int arc_finish_radians = 270;  
  100.     // 左下角开始  
  101.     private int start_arc = 135;  
  102.   
  103.     private float[] pointerPosition;  
  104.     private Paint mColorCenterHalo;  
  105.     private RectF mColorCenterHaloRectangle = new RectF();  
  106.     private int end_wheel;  
  107.   
  108.     private Bitmap pointerBitmap;  
  109.     private boolean show_text = false;  
  110.   
  111.     public ZJBCircleSeekBar(Context context) {  
  112.         super(context);  
  113.         init(null, 0);  
  114.     }  
  115.   
  116.     public ZJBCircleSeekBar(Context context, AttributeSet attrs) {  
  117.         super(context, attrs);  
  118.         init(attrs, 0);  
  119.     }  
  120.   
  121.     public ZJBCircleSeekBar(Context context, AttributeSet attrs, int defStyle) {  
  122.         super(context, attrs, defStyle);  
  123.         init(attrs, defStyle);  
  124.     }  
  125.   
  126.     private void init(AttributeSet attrs, int defStyle) {  
  127.         final TypedArray a = getContext().obtainStyledAttributes(attrs,  
  128.                 R.styleable.HoloCircleSeekBar, defStyle, 0);  
  129.   
  130.         initAttributes(a);  
  131.   
  132.         a.recycle();  
  133.         // mAngle = (float) (-Math.PI / 2);  
  134.   
  135.         mColorWheelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);  
  136.         mColorWheelPaint.setShader(s);  
  137.         mColorWheelPaint.setColor(Color.BLACK);  
  138.         mColorWheelPaint.setStyle(Paint.Style.STROKE);  
  139.         mColorWheelPaint.setStrokeWidth(mColorWheelStrokeWidth);  
  140.   
  141.         mColorCenterHalo = new Paint(Paint.ANTI_ALIAS_FLAG);  
  142.         mColorCenterHalo.setColor(Color.CYAN);  
  143.         mColorCenterHalo.setAlpha(0xCC);  
  144.         // mColorCenterHalo.setStyle(Paint.Style.STROKE);  
  145.         // mColorCenterHalo.setStrokeWidth(mColorCenterHaloRectangle.width() /  
  146.         // 2);  
  147.   
  148.         mPointerHaloPaint = new Paint(Paint.ANTI_ALIAS_FLAG);  
  149.         mPointerHaloPaint.setColor(Color.GREEN);  
  150.         mPointerHaloPaint.setStrokeWidth(mPointerRadius + 10);  
  151.         // mPointerHaloPaint.setAlpha(150);  
  152.         // 游标图片  
  153.         pointerBitmap = BitmapFactory.decodeResource(this.getResources(),  
  154.                 R.drawable.pointer);  
  155.   
  156.         mPointerColor = new Paint(Paint.ANTI_ALIAS_FLAG);  
  157.         mPointerColor.setStrokeWidth(mPointerRadius);  
  158.   
  159.         // 设置游标指针的颜色  
  160.         mPointerColor.setColor(Color.GREEN);  
  161.   
  162.         // 设置游标滑过的背景属性  
  163.         mArcColor = new Paint(Paint.ANTI_ALIAS_FLAG);  
  164.         mArcColor.setColor(Color.GREEN);  
  165.         mArcColor.setStyle(Paint.Style.STROKE);  
  166.         mArcColor.setStrokeWidth(mColorWheelStrokeWidth);  
  167.   
  168.         arc_finish_radians = (int) calculateAngleFromText(init_position) - 90;  
  169.   
  170.         if (arc_finish_radians > end_wheel)  
  171.             arc_finish_radians = end_wheel;  
  172.         mAngle = calculateAngleFromRadians(arc_finish_radians > end_wheel ? end_wheel  
  173.                 : arc_finish_radians);  
  174.         text = String.valueOf(calculateTextFromAngle(arc_finish_radians));  
  175.   
  176.         invalidate();  
  177.     }  
  178.   
  179.     private void initAttributes(TypedArray a) {  
  180.   
  181.         max = a.getInteger(R.styleable.HoloCircleSeekBar_max, 100);  
  182.   
  183.         color_attr = a.getString(R.styleable.HoloCircleSeekBar_color);  
  184.         wheel_color_attr = a  
  185.                 .getString(R.styleable.HoloCircleSeekBar_wheel_active_color);  
  186.         wheel_unactive_color_attr = a  
  187.                 .getString(R.styleable.HoloCircleSeekBar_wheel_unactive_color);  
  188.         pointer_color_attr = a  
  189.                 .getString(R.styleable.HoloCircleSeekBar_pointer_color);  
  190.         pointer_halo_color_attr = a  
  191.                 .getString(R.styleable.HoloCircleSeekBar_pointer_halo_color);  
  192.   
  193.         a.getString(R.styleable.HoloCircleSeekBar_text_color);  
  194.   
  195.         a.getInteger(R.styleable.HoloCircleSeekBar_text_size, 95);  
  196.   
  197.         init_position = a.getInteger(  
  198.                 R.styleable.HoloCircleSeekBar_init_position, 0);  
  199.   
  200.         start_arc = a.getInteger(R.styleable.HoloCircleSeekBar_start_angle, 0);  
  201.         end_wheel = a.getInteger(R.styleable.HoloCircleSeekBar_end_angle, 360);  
  202.   
  203.         show_text = a.getBoolean(R.styleable.HoloCircleSeekBar_show_text, true);  
  204.   
  205.         last_radians = end_wheel;  
  206.   
  207.         if (init_position < start_arc)  
  208.             init_position = calculateTextFromStartAngle(start_arc);  
  209.   
  210.         // mAngle = (float) calculateAngleFromText(init_position);  
  211.   
  212.         if (color_attr != null) {  
  213.             try {  
  214.                 Color.parseColor(color_attr);  
  215.             } catch (IllegalArgumentException e) {  
  216.             }  
  217.             Color.parseColor(color_attr);  
  218.         } else {  
  219.         }  
  220.   
  221.         if (wheel_color_attr != null) {  
  222.             try {  
  223.                 Color.parseColor(wheel_color_attr);  
  224.             } catch (IllegalArgumentException e) {  
  225.             }  
  226.   
  227.         } else {  
  228.         }  
  229.         if (wheel_unactive_color_attr != null) {  
  230.             try {  
  231.                 Color.parseColor(wheel_unactive_color_attr);  
  232.             } catch (IllegalArgumentException e) {  
  233.             }  
  234.   
  235.         } else {  
  236.         }  
  237.   
  238.         if (pointer_color_attr != null) {  
  239.             try {  
  240.                 Color.parseColor(pointer_color_attr);  
  241.             } catch (IllegalArgumentException e) {  
  242.             }  
  243.   
  244.         } else {  
  245.         }  
  246.   
  247.         if (pointer_halo_color_attr != null) {  
  248.             try {  
  249.                 Color.parseColor(pointer_halo_color_attr);  
  250.             } catch (IllegalArgumentException e) {  
  251.             }  
  252.   
  253.         } else {  
  254.         }  
  255.   
  256.     }  
  257.   
  258.     @Override  
  259.     protected void onDraw(Canvas canvas) {  
  260.         canvas.translate(mTranslationOffset, mTranslationOffset);  
  261.   
  262.         // 滑过的弧  
  263.         canvas.drawArc(mColorWheelRectangle, start_arc + 270, end_wheel  
  264.                 - (start_arc), false, mColorWheelPaint);  
  265.   
  266.         // 背景弧  
  267.         canvas.drawArc(mColorWheelRectangle, start_arc + 270,  
  268.                 (arc_finish_radians) > (end_wheel) ? end_wheel - (start_arc)  
  269.                         : arc_finish_radians - start_arc, false, mArcColor);  
  270.         // 游标为圆形  
  271.         // canvas.drawCircle(pointerPosition[0], pointerPosition[1],  
  272.         // mPointerRadius, mPointerHaloPaint);  
  273.         //  
  274.         // canvas.drawCircle(pointerPosition[0], pointerPosition[1],  
  275.         // (float) (mPointerRadius / 1.2), mPointerColor);  
  276.   
  277.         // 游标为方形  
  278.         // canvas.drawRect(pointerPosition[0] - 50, pointerPosition[1] - 30,  
  279.         // pointerPosition[0] + 50, pointerPosition[1] + 30, mPointerColor);  
  280.   
  281.         // 游标为图片  
  282.         canvas.drawBitmap(pointerBitmap, pointerPosition[0] - 50,  
  283.                 pointerPosition[1] - 115, null);  
  284.   
  285.         // 添加游标上的文字  
  286.         Paint pai = new Paint();  
  287.         pai.setColor(Color.BLACK);  
  288.         pai.setTextSize(50);  
  289.         canvas.drawText(text, pointerPosition[0] - 30, pointerPosition[1] - 40,  
  290.                 pai);  
  291.   
  292.     }  
  293.   
  294.     @Override  
  295.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
  296.         int height = getDefaultSize(getSuggestedMinimumHeight(),  
  297.                 heightMeasureSpec);  
  298.         int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);  
  299.         int min = Math.min(width, height);  
  300.         setMeasuredDimension(min, min);  
  301.   
  302.         mTranslationOffset = min * 0.5f;  
  303.         mColorWheelRadius = mTranslationOffset - mPointerRadius;  
  304.   
  305.         mColorWheelRectangle.set(-mColorWheelRadius, -mColorWheelRadius,  
  306.                 mColorWheelRadius, mColorWheelRadius);  
  307.   
  308.         mColorCenterHaloRectangle.set(-mColorWheelRadius / 2,  
  309.                 -mColorWheelRadius / 2, mColorWheelRadius / 2,  
  310.                 mColorWheelRadius / 2);  
  311.   
  312.         pointerPosition = calculatePointerPosition(mAngle);  
  313.   
  314.     }  
  315.   
  316.     private int calculateTextFromAngle(float angle) {  
  317.         float m = angle - start_arc;  
  318.   
  319.         float f = (float) ((end_wheel - start_arc) / m);  
  320.   
  321.         return (int) (max / f);  
  322.     }  
  323.   
  324.     private int calculateTextFromStartAngle(float angle) {  
  325.         float m = angle;  
  326.   
  327.         float f = (float) ((end_wheel - start_arc) / m);  
  328.   
  329.         return (int) (max / f);  
  330.     }  
  331.   
  332.     private double calculateAngleFromText(int position) {  
  333.         if (position == 0 || position >= max)  
  334.             return (float) 90;  
  335.   
  336.         double f = (double) max / (double) position;  
  337.   
  338.         double f_r = 360 / f;  
  339.   
  340.         double ang = f_r + 90;  
  341.   
  342.         return ang;  
  343.   
  344.     }  
  345.   
  346.     private int calculateRadiansFromAngle(float angle) {  
  347.         float unit = (float) (angle / (2 * Math.PI));  
  348.         if (unit < 0) {  
  349.             unit += 1;  
  350.         }  
  351.         int radians = (int) ((unit * 360) - ((360 / 4) * 3));  
  352.         if (radians < 0)  
  353.             radians += 360;  
  354.         return radians;  
  355.     }  
  356.   
  357.     private float calculateAngleFromRadians(int radians) {  
  358.         return (float) (((radians + 270) * (2 * Math.PI)) / 360);  
  359.     }  
  360.   
  361.     public int getValue() {  
  362.         return conversion;  
  363.     }  
  364.   
  365.     @Override  
  366.     public boolean onTouchEvent(MotionEvent event) {  
  367.         // Convert coordinates to our internal coordinate system  
  368.         float x = event.getX() - mTranslationOffset;  
  369.         float y = event.getY() - mTranslationOffset;  
  370.   
  371.         switch (event.getAction()) {  
  372.         case MotionEvent.ACTION_DOWN:  
  373.             // Check whether the user pressed on (or near) the pointer  
  374.             mAngle = (float) java.lang.Math.atan2(y, x);  
  375.   
  376.             block_end = false;  
  377.             block_start = false;  
  378.             mUserIsMovingPointer = true;  
  379.   
  380.             arc_finish_radians = calculateRadiansFromAngle(mAngle);  
  381.   
  382.             if (arc_finish_radians > end_wheel) {  
  383.                 arc_finish_radians = end_wheel;  
  384.                 block_end = true;  
  385.             }  
  386.   
  387.             if (!block_end && !block_start) {  
  388.                 text = String  
  389.                         .valueOf(calculateTextFromAngle(arc_finish_radians));  
  390.                 pointerPosition = calculatePointerPosition(mAngle);  
  391.                 invalidate();  
  392.             }  
  393.             break;  
  394.         case MotionEvent.ACTION_MOVE:  
  395.             if (mUserIsMovingPointer) {  
  396.                 mAngle = (float) java.lang.Math.atan2(y, x);  
  397.   
  398.                 int radians = calculateRadiansFromAngle(mAngle);  
  399.   
  400.                 if (last_radians > radians && radians < (360 / 6) && x > lastX  
  401.                         && last_radians > (360 / 6)) {  
  402.   
  403.                     if (!block_end && !block_start)  
  404.                         block_end = true;  
  405.   
  406.                 } else if (last_radians >= start_arc  
  407.                         && last_radians <= (360 / 4) && radians <= (360 - 1)  
  408.                         && radians >= ((360 / 4) * 3) && x < lastX) {  
  409.                     if (!block_start && !block_end)  
  410.                         block_start = true;  
  411.   
  412.                 } else if (radians >= end_wheel && !block_start  
  413.                         && last_radians < radians) {  
  414.                     block_end = true;  
  415.                 } else if (radians < end_wheel && block_end  
  416.                         && last_radians > end_wheel) {  
  417.                     block_end = false;  
  418.                 } else if (radians < start_arc && last_radians > radians  
  419.                         && !block_end) {  
  420.                     block_start = true;  
  421.                 } else if (block_start && last_radians < radians  
  422.                         && radians > start_arc && radians < end_wheel) {  
  423.                     block_start = false;  
  424.                 }  
  425.   
  426.                 if (block_end) {  
  427.   
  428.                     arc_finish_radians = end_wheel - 1;  
  429.                     text = String.valueOf(0);  
  430.                     mAngle = calculateAngleFromRadians(arc_finish_radians);  
  431.                     pointerPosition = calculatePointerPosition(mAngle);  
  432.                 } else if (block_start) {  
  433.   
  434.                     arc_finish_radians = start_arc;  
  435.                     mAngle = calculateAngleFromRadians(arc_finish_radians);  
  436.                     text = String.valueOf(0);  
  437.                     pointerPosition = calculatePointerPosition(mAngle);  
  438.                 } else {  
  439.                     // text = String.valueOf(calculateTextFromAngle(mAngle));  
  440.                     arc_finish_radians = calculateRadiansFromAngle(mAngle);  
  441.                     text = String  
  442.                             .valueOf(calculateTextFromAngle(arc_finish_radians));  
  443.                     pointerPosition = calculatePointerPosition(mAngle);  
  444.                 }  
  445.                 invalidate();  
  446.                 if (mOnCircleSeekBarChangeListener != null)  
  447.                     mOnCircleSeekBarChangeListener.onProgressChanged(this,  
  448.                             Integer.parseInt(text), true);  
  449.   
  450.                 last_radians = radians;  
  451.   
  452.             }  
  453.             break;  
  454.         case MotionEvent.ACTION_UP:  
  455.             mUserIsMovingPointer = false;  
  456.             break;  
  457.         }  
  458.         if (event.getAction() == MotionEvent.ACTION_MOVE && getParent() != null) {  
  459.             getParent().requestDisallowInterceptTouchEvent(true);  
  460.         }  
  461.         lastX = x;  
  462.   
  463.         return true;  
  464.     }  
  465.   
  466.     /** 
  467.      * Calculate the pointer's coordinates on the color wheel using the supplied 
  468.      * angle. 
  469.      *  
  470.      * @param angle 
  471.      *            The position of the pointer expressed as angle (in rad). 
  472.      *  
  473.      * @return The coordinates of the pointer's center in our internal 
  474.      *         coordinate system. 
  475.      */  
  476.     private float[] calculatePointerPosition(float angle) {  
  477.         // if (calculateRadiansFromAngle(angle) > end_wheel)  
  478.         // angle = calculateAngleFromRadians(end_wheel);  
  479.         float x = (float) (mColorWheelRadius * Math.cos(angle));  
  480.         float y = (float) (mColorWheelRadius * Math.sin(angle));  
  481.   
  482.         return new float[] { x, y };  
  483.     }  
  484.   
  485.     @Override  
  486.     protected Parcelable onSaveInstanceState() {  
  487.         Parcelable superState = super.onSaveInstanceState();  
  488.   
  489.         Bundle state = new Bundle();  
  490.         state.putParcelable(STATE_PARENT, superState);  
  491.         state.putFloat(STATE_ANGLE, mAngle);  
  492.   
  493.         return state;  
  494.     }  
  495.   
  496.     @Override  
  497.     protected void onRestoreInstanceState(Parcelable state) {  
  498.         Bundle savedState = (Bundle) state;  
  499.   
  500.         Parcelable superState = savedState.getParcelable(STATE_PARENT);  
  501.         super.onRestoreInstanceState(superState);  
  502.   
  503.         mAngle = savedState.getFloat(STATE_ANGLE);  
  504.         arc_finish_radians = calculateRadiansFromAngle(mAngle);  
  505.         text = String.valueOf(calculateTextFromAngle(arc_finish_radians));  
  506.         pointerPosition = calculatePointerPosition(mAngle);  
  507.   
  508.     }  
  509.   
  510.     public void setOnSeekBarChangeListener(OnCircleSeekBarChangeListener l) {  
  511.         mOnCircleSeekBarChangeListener = l;  
  512.     }  
  513.   
  514.     public interface OnCircleSeekBarChangeListener {  
  515.   
  516.         public abstract void onProgressChanged(ZJBCircleSeekBar seekBar,  
  517.                 int progress, boolean fromUser);  
  518.   
  519.     }  
  520.   
  521. }  


/layout/activity_main.xml:

 

 

  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:layout_gravity="center_horizontal"  
  6.     tools:context=".MainActivity" >  
  7.   
  8.     <TextView  
  9.         android:id="@+id/text"  
  10.         android:layout_width="fill_parent"  
  11.         android:layout_height="wrap_content"  
  12.         android:layout_centerHorizontal="true"  
  13.         android:layout_marginTop="80dp"  
  14.         android:gravity="center_horizontal"  
  15.         android:textSize="60sp"   
  16.         android:textColor="#ffff0000"  
  17.         />  
  18.   
  19.     <com.example.circleseekbar.HoloCircleSeekBar  
  20.         android:id="@+id/c"  
  21.         android:layout_width="500px"  
  22.         android:layout_height="500px"  
  23.         android:layout_centerInParent="true" />  
  24.   
  25. </RelativeLayout>  


MainActivity.java:

 

 

  1. package com.example.circleseekbar;  
  2.   
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5. import android.widget.TextView;  
  6.   
  7. import com.example.circleseekbar.ZJBCircleSeekBar.OnCircleSeekBarChangeListener;  
  8.   
  9. /** 
  10.  * @author zjbpku 
  11.  * @time 2013-08-21 
  12.  * @blog http://blog.csdn.net/zjbpku 
  13.  */  
  14. public class MainActivity extends Activity implements  
  15.         OnCircleSeekBarChangeListener {  
  16.   
  17.     private ZJBCircleSeekBar circleSeekBar;  
  18.     TextView textView;  
  19.   
  20.     @Override  
  21.     protected void onCreate(Bundle savedInstanceState) {  
  22.         // TODO Auto-generated method stub  
  23.         super.onCreate(savedInstanceState);  
  24.         setContentView(R.layout.activity_main);  
  25.         circleSeekBar = (ZJBCircleSeekBar) findViewById(R.id.c);  
  26.         textView = (TextView) findViewById(R.id.text);  
  27.         circleSeekBar.setOnSeekBarChangeListener(this);  
  28.     }  
  29.   
  30.     @Override  
  31.     public void onProgressChanged(ZJBCircleSeekBar seekBar, int progress,  
  32.             boolean fromUser) {  
  33.         // TODO Auto-generated method stub  
  34.         textView.setText(progress + "");  
  35.     }  
  36.   
  37. }  

小编很辛苦,请尊重菜鸟的劳动成果,转载请注明出处:http://blog.csdn.net/zjbpku/article/details/10140815

原文地址:https://www.cnblogs.com/Free-Thinker/p/4507795.html