title: "Animators may only be run on Looper threads" error when loading an image to ImageView from assets folder (Android)
body: <p>I am trying to build some methods that allow me to load one .png image at a time from a local folder, using the image's name. I have chosen to load from the <code>assets</code> folder since the <code>res</code> folder does not load by image name. Having read around a fair few Q&amp;As, I have produced the following method:</p>
  <pre><code>    private void setImage(String imageName) {
          String imageReference = String.format(&quot;%1$s/%2$s&quot;, &quot;images&quot;, imageName);
          Context appContext = getContext().getApplicationContext();
          AssetManager assetManager = appContext.getAssets();
          // get input stream
          InputStream inputStream = null;
          try {
              inputStream = assetManager.open(imageReference);
          } catch (IOException e) {
              e.printStackTrace();
          }
          // load image as drawable
          Drawable drawable = null;
          drawable = Drawable.createFromStream(inputStream, null);
          // set image to ImageView
          imageView.setImageDrawable(drawable);
          try {
              inputStream .close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  <p>...where &quot;images&quot; is a subdirectory within the assets folder. Using the debugger, I can see that the method is successfully picking up an image, but as soon as it hits the line of code <code>imageView.setImageDrawable(drawable);</code>, the emulator throws the following error:
  <code>AndroidRuntimeException: Animators may only be run on Looper threads</code></p>
  <p>I have tried to work out what this means, in terms of my usage, but have failed so far. Any help/advice gratefully received :)</p>
  <p><strong>EDIT</strong>: Here is my latest stacktrace, which (perculiarly) has changed slightly since I posted my question:</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: Timer-3
      Process: com.example.spineapp.debug, PID: 10369
      android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
          at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7753)
          at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1225)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.widget.ScrollView.requestLayout(ScrollView.java:1533)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.view.View.requestLayout(View.java:23093)
          at android.widget.ImageView.setImageDrawable(ImageView.java:571)
          at android.support.v7.widget.AppCompatImageView.setImageDrawable(AppCompatImageView.java:100)
          at com.spineapp.LeftRightJudgementStepLayout.setImage(LeftRightJudgementStepLayout.java:583)
          at com.spineapp.LeftRightJudgementStepLayout.startQuestion(LeftRightJudgementStepLayout.java:521)
          at com.spineapp.LeftRightJudgementStepLayout.startNextQuestionOrFinish(LeftRightJudgementStepLayout.java:1031)
          at com.spineapp.LeftRightJudgementStepLayout$7.run(LeftRightJudgementStepLayout.java:482)
          at java.util.TimerThread.mainLoop(Timer.java:562)
          at java.util.TimerThread.run(Timer.java:512)
  </code></pre>