RunOnUiThread (new Runnable () error {punctuation (token)

Somehow this does not work, for me it should be like this:

public void Splash(){
    Timer timer= new Timer();

    timer.schedule(new TimerTask(){ 

    MexGame.this.runOnUiThread(new Runnable() {

      public void run(){
      SplashImage.setImageDrawable(aktieknop);
      } //Closes run()

      }); //Closes runOnUiThread((){})

  },SplashTime); //Closes the Timeratask((){})

} //closes Splash()

Does anyone know where I am missing something?

FORMAL COMMENT I know a stupid problem, or maybe I'm doing something impossible, but I tried all the logical possibilities. So something is probably missing or I'm trying to do something that is impossible. Could you help me. I am trying to use the following code, but this gives problems with the token:

 Timer timer= new Timer();
   timer.schedule(new TimerTask(){

     runOnUiThread(new Runnable() {

      public void run(){
      SplashImage.setImageDrawable(aktieknop);}

      });}

  },SplashTime);

If I block runOnUiThread, it will work, since I am trying to adapt the user interface from another thread, but at least there is no problem with the token, does anyone know?

   Timer timer= new Timer();


  timer.schedule(new TimerTask(){

//   runOnUiThread(new Runnable() {

      public void run(){
      SplashImage.setImageDrawable(aktieknop);}

    //  });}

  },SplashTime);
+5
2

TimerTask, Runnable , run, run.

, Runnable TimerTask.

   final Runnable setImageRunnable = new Runnable() {
        public void run() {
             splashImage.setImageDrawable(aktieknop);
        }
    };

    TimerTask task = new TimerTask(){
        public void run() {
            getActivity().runOnUiThread(setImageRunnable);
        }
    };

    Timer timer = new Timer();
    timer.schedule(task, splashTime);
+9

"}" SplashTime. "{" "}" , "}" .

Timer timer= new Timer();
timer.schedule(new TimerTask(){
        runOnUiThread(new Runnable() {
            public void run(){
                SplashImage.setImageDrawable(aktieknop);
            }   //closes run(){}         
        });     //closes runOnUiThread( Runnable(){ }); 
    },          //closes TimerTask(){}
    SplashTime);
+1

All Articles