hi, i dnt know why thread is not running in my code also, it only runs
once, here is my code, no error no message,
will you please help me.

package com.Arcs;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

public class ArcTest extends Activity
{
        SampleView sv;

        public void onCreate(Bundle savedInstanceState)
        {
        super.onCreate(savedInstanceState);
        sv=new SampleView(this);
        setContentView(sv);
    }



        int mySecondsTotal;

        @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
//              sv.invalidate();
         switch(keyCode){
              case KeyEvent.KEYCODE_DPAD_UP:
                   this.mySecondsTotal += 60; // One minute later
                   sv.f++;
                   break;
              case KeyEvent.KEYCODE_DPAD_DOWN:
                   this.mySecondsTotal -= 60; // One minute earlier
                   sv.f--;
                   break;
              case KeyEvent.KEYCODE_DPAD_CENTER:
                    // START / PAUSE
                   break;
              case KeyEvent.KEYCODE_DPAD_LEFT:
                   this.mySecondsTotal += 1; // One second later
                   break;
              case KeyEvent.KEYCODE_DPAD_RIGHT:
                   this.mySecondsTotal -= 1; // One second earlier
                   break;
              default:
                   return super.onKeyDown(keyCode, event);
         }


         return true;
    }

        public boolean onKeyUp(int keyCode, KeyEvent event)
        {
                return true;
        }

}

class SampleView extends View implements Runnable
{
        Paint paint;
        RectF oval;
        float f,j=360;
        boolean running=true;

        SampleView(Context arc)
        {
                super(arc);
                paint=new Paint();
                paint.setColor(0x88FF0000);
                Thread t=new Thread(this);
                t.start();
                t.setPriority(10);
        }

        protected void onDraw(Canvas canvas)
        {
                System.out.println("in ondraw");
                canvas.drawColor(Color.WHITE);
                oval=new RectF(10,10,280,250);
                canvas.drawArc(oval, f, j, true, paint);
                canvas.drawText(""+j, 30, 300, paint);
//              f++;
//              if(f>360)
//                      f=0;
//              j--;
//              if(j<0)
//                      j=360;
//              invalidate();

        }

        public void run()
        {
                try{
                        while(true)
                        {
                                j--;
                                if(j<0)
                                        j=360;
                                invalidate();
                                Thread.sleep(150);
                                System.out.println("in thread");
                        }
                }catch(Exception e){e.printStackTrace();}
        }

}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to