title: MultiThread in Android for Loop and Delay
body: <p>As you can see, I have to do TASK1 and continually TASK2. Between 1 and 2, they have delay. And then I want to repeat it infinitely till activity will be finished.</p>
  
  <p>I have no experience for thread.. I can't fix this error.
  Help ME!</p>
  
  <pre><code>      Timer timer = new Timer();
        timer.schedule(new TimerTask() {
  
            @Override
            public void run() {
            //TASK 1
            main_1.setVisibility(View.VISIBLE);
            main_2.setVisibility(View.INVISIBLE);
            main_1.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_in_left));
  
  
                  Handler mHandler = new Handler(Looper.getMainLooper());
                  mHandler.postDelayed(new Runnable() {
                      @Override
                      public void run() {
                      //TASK 2
                      main_1.setVisibility(View.INVISIBLE);
                      main_2.setVisibility(View.VISIBLE);
                      main_2.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_in_left));
  
                      }
                  }, 1000);
                  }
              }, 1000, 1000);
  </code></pre>
  
  <p>And it's my error</p>
  
  <pre><code>android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
  </code></pre>