View switch using ViewFlipper

When I get my application back, I can choose which view to display in my Flipper view by running:

viewFlipper.setDisplayedChild(1);

in onCreate, I can switch the view in my onClick ()

viewFlipper.setDisplayedChild(0);

When I want to switch a child from my code (not in my main application), I get the following problem:

02-02 12:17:08.620: ERROR/AndroidRuntime(1005): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

Any help is appreciated.

+3
source share
1 answer

Call setDisplayedChild()only from the main thread of the application, not from the background thread.

+5
source

Source: https://habr.com/ru/post/1789473/


All Articles