android animator.java,java - Animators may only be run on Looper threads Android - Stack Overflow

嵇财
2023-12-01

I'm trying to animate something when a task is completed. The problem here is I get this error message:

android.util.AndroidRuntimeException: Animators may only be run on Looper threads

at android.animation.ValueAnimator.cancel(ValueAnimator.java:1004)

at android.view.ViewPropertyAnimator.animatePropertyBy(ViewPropertyAnimator.java:965)

at android.view.ViewPropertyAnimator.animateProperty(ViewPropertyAnimator.java:921)

at android.view.ViewPropertyAnimator.alpha(ViewPropertyAnimator.java:735)

at com.design.zaton.prototypei.MainActivity$1$1.run(MainActivity.java:93)

at java.lang.Thread.run(Thread.java:761)

The app worked fine before with the same exact code but now it simply doesn't. I'm really confused.

Here's where the error happens:

new Thread(new Runnable() {

@Override

public void run() {

final String s = getGiphyViews(String.valueOf(mEdit.getText()));

runOnUiThread(new Runnable() {

@Override

public void run() {

result.setText(s);

}

});

loading.animate()

.alpha(0)

.setDuration(100);

done.animate()

.scaleY(1)

.scaleX(1)

.setDuration(300);

}

}).start();

The error outlines the loading.animate() method.

Thanks in advance!

 类似资料: