I saw a piece of code online. I am wondering why we need to use runnable to set TextView text? Thank!
while (true) { // listen for incoming clients Socket client = serverSocket.accept(); handler.post(new Runnable() { @Override public void run() { serverStatus.setText("Connected."); } });
http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/
, ? UI - . , . , , - UI (, serverStatus), . .
. UI , . , , , Runnables.
( ), : http://developer.android.com/guide/appendix/faq/commontasks.html#threading
. ( edittext) Uithread. Runnable . : http://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable)
Source: https://habr.com/ru/post/1781550/More articles:The PROMOTE TRANSACTION request failed because the local transaction is inactive - .net-4.0ASP.NET MVC 2: view subfolders? - asp.net-mvc-2Linq to Entities in EF4 using generated POCO classes - entity-frameworkPaperclip: Missing Image - ruby-on-railsCalling the Google UI API through Python - pythonHow do I add an icon to the Customize toolbar? - firefoxIs there any useful use of readyState other than "4" (full) in the XHR.onreadystatechange callback? - javascriptcommon method for clearform in asp.net? - asp.netIn parsing theory, what is the opposite of "inferring"? - terminologyPattern for repeating queries Parameter - c #All Articles