在 2011年1月15日星期六,Kostya Vasilyev <kmans...@gmail.com> 写道:
> Braco,
>
> You are using a Java Timer, which invokes your TimerTask on a background 
> thread.
> In Android, only the original (UI) thread is allowed to touch the UI. 
> Touching the UI from a background thread, like your code does, produces 
> unpredictable results (possibly a crash).
>
> This should help you refactor you code:
> http://developer.android.com/resources/articles/timed-ui-updates.html
>
> -- Kostya
> 2011/1/13 braco_ <braco...@googlemail.com>
>
> Hello,
>
> I have 4 Images
>         final ImageView redImage = (ImageView) findViewById
> (R.id.circle_red);
>         final ImageView blueImage = (ImageView) findViewById
> (R.id.circle_blue);
>         final ImageView greenImage = (ImageView) findViewById
> (R.id.circle_green);
>         final ImageView yellowImage = (ImageView) findViewById
> (R.id.circle_yellow);
>
> I try to blinking this images with a timer
> final Timer timer = new Timer();
>
> startButton.setOnClickListener(new View.OnClickListener() {
>                         @Override
>                         public void onClick(View v) {
>                                 // TODO Auto-generated method stub
>
>
>                                 timer.schedule(new 
> TaskTimer(yellowImage,punkteStand), 0, 2000);
>                         }
> });
>
> TaskTimer.java
> public TaskTimer(ImageView object, TextView pkt){
>                 image =  object;
>                 punkteStand = pkt;
>         }
>
>
>         @Override
>         public void run() {
>                 // TODO Auto-generated method stub
>                 String istString = (new Integer(time)).toString();
>                 CharSequence abc = istString;
>                 punkteStand.setText(abc);
>                 time++;
>                 if(image.getVisibility() == View.INVISIBLE){
>                         image.setVisibility(View.VISIBLE);
>                 }
>                 else {
>                         image.setVisibility(View.INVISIBLE);
>
>                 }
>
> But if i start nothing happens how can i do that better that a image
> will blinking?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
Best Regards

Felix Long

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to