반응형
Thread UI 처리에 대한 샘플
public class YourClass extends Activity { private Button myButton; //create an handler private final Handler myHandler = new Handler(); final Runnable updateRunnable = new Runnable() { public void run() { //call the activity method that updates the UI updateUI(); } }; private void updateUI() { // ... update the UI } private void doSomeHardWork() { //.... hard work //update the UI using the handler and the runnable myHandler.post(updateRunnable); } private OnClickListener buttonListener = new OnClickListener() { public void onClick(View v) { new Thread(new Runnable() { doSomeHardWork(); }).start(); } };}http://crodrigues.com/updating-the-ui-from-a-background-thread-on-android/
반응형
'Android Coding' 카테고리의 다른 글
| Android Acitivty restart (0) | 2018.08.03 |
|---|---|
| [NDK] chars To JString (0) | 2018.04.09 |
| ScrollView 안에서의 RecyclerView시 Smooth Scroll (0) | 2017.11.11 |
| 파일 삭제 Task (0) | 2017.11.10 |
| Menu item Background 변경 처리 (0) | 2017.09.20 |