Progress wheel

main.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:clipChildren="true"
    android:background="@drawable/login_gradient_flip" >

    <RelativeLayout android:id="@+id/rl_login_header"
        android:layout_width="fill_parent"
        android:layout_height="160dp"
        android:background="@drawable/header"   
        android:layout_alignParentTop="true" >
   
        <ImageView android:id="@+id/iv_login_header_image"
            android:layout_width="250dp"
            android:layout_height="77dp"
            android:scaleType="centerInside"
            android:src="@drawable/logo"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_centerInParent="true" />
   
    </RelativeLayout>
   
    <View android:layout_width="fill_parent"
        android:layout_height="67dp"
        android:id="@+id/v_login_gradient"
        android:background="@drawable/login_gradient"
        android:layout_below="@id/rl_login_header" />
   
    <ViewFlipper android:id="@+id/vf_login_flipper"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="-67dp"
        android:layout_below="@id/v_login_gradient"
        android:background="@null" >
   
        <RelativeLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@null" >
           
            <LinearLayout android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_marginTop="35dp" >
           
                <com.visualdenim.schooltraq.progressbar.NewProgressSpinner
                    android:id="@+id/progressBar"
                    android:layout_width="250dp"
                    android:layout_height="250dp" />
           
            </LinearLayout>
           
        </RelativeLayout>   
   
    </ViewFlipper>
              
</RelativeLayout>


main.java


package moor.android.wheel;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Shader;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * A sample activity showing some of the functions of the progress bar
 */
public class main extends Activity {
    boolean running;
    ProgressWheel pw_two;
    ProgressWheel pw_three;
    ProgressWheel pw_four;
    //ProgressWheel pw_five;
    int progress = 0;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.progress_wheel_activity);
        pw_two = (ProgressWheel) findViewById(R.id.progressBarTwo);
        pw_three = (ProgressWheel) findViewById(R.id.progressBarThree);
        pw_four = (ProgressWheel) findViewById(R.id.progressBarFour);
        //pw_five = (ProgressWheel) findViewById(R.id.progressBarFive);
       
        ShapeDrawable bg = new ShapeDrawable(new RectShape());
        int[] pixels = new int[] { 0xFF2E9121, 0xFF2E9121, 0xFF2E9121,
            0xFF2E9121, 0xFF2E9121, 0xFF2E9121, 0xFFFFFFFF, 0xFFFFFFFF};
        Bitmap bm = Bitmap.createBitmap(pixels, 8, 1, Bitmap.Config.ARGB_8888);
        Shader shader = new BitmapShader(bm,
            Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        pw_three.setRimShader(shader);
       
        pw_three.spin();
        pw_four.spin();
       
        final Runnable r = new Runnable() {
            public void run() {
                running = true;
                while(progress<361) {
                    pw_two.incrementProgress();
                    progress++;
                    try {
                        Thread.sleep(15);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
                running = false;
            }
        };
       
        Button spin = (Button) findViewById(R.id.btn_spin);
        spin.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if(!running) {
                    if(pw_two.isSpinning) {
                        pw_two.stopSpinning();
                    }
                    pw_two.resetCount();
                    pw_two.setText("Loading...");
                    pw_two.spin();
                }
            }
        });
       
        Button increment = (Button) findViewById(R.id.btn_increment);
        increment.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if(!running) {
                    progress = 0;
                    pw_two.resetCount();
                    Thread s = new Thread(r);
                    s.start();
                }
            }
        });
    }
   
    @Override
    public void onPause() {
        super.onPause();
        progress = 361;
        pw_two.stopSpinning();
        pw_two.resetCount();
        pw_two.setText("Click\none of the\nbuttons");
    }
}

Screen shot :






 


Download source...

5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Not working because this was stolen from an open source project. This guy is NOT the author and he is plagiarizing, poorly, with absolutely NO instruction

    ReplyDelete
  3. i want code for like love calculator display the percentage with diff number

    ReplyDelete
  4. super thanks. it's working...
    Below Library is the base.
    https://github.com/Todd-Davies/ProgressWheel

    ReplyDelete