Setting up TextView visible from another thread or BeginInvoke in Android

I am developing an application for Android 2.2.

I have an event listener in action and I want to set the visible TextView when I receive the event. But there is an error:

I can install it only from the user interface thread.

In C # and Windows Mobile there is BeginInvoke. Is there something similar in Android?

Thanks.

+4
source share
1 answer

You can use Activity#runOnUiThread or AsyncTask as the two easiest ways to duplicate BeginInvoke functionality; where runOnUiThread is the most similar.

For more complex or performance-oriented needs (i.e. you do not want to create a large number of Runnable objects), you can use Handler . However, I do not recommend it as your first choice.

0
source

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


All Articles