일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- #1차원배열
- html youtube
- #자바상속#자바이즈어#is~a
- docker example
- html video
- git flow
- #bubbleSort
- border-box
- html object
- #CallByAddress
- html plug-in
- #C++ has~a
- html5 new tag
- #android activity
- html code
- #다차원포인터
- #3차원배열
- mac terminal command
- #JAVASCRIPT
- 토큰경제
- #C++ 연산자함수오버로딩
- #2차원배열
- html charset
- 하이퍼레저패브릭
- relative path
- html multimedia
- html id
- #성적관리프로그램
- hyperledger transaction
- #binary
Archives
- Today
- Total
A sentimental robot
Thread를 이용한 UI 본문
package com.example.i310_54.myapplication08;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void f1(View view) {
new Thread() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Button btn1 = findViewById(R.id.b);
btn1.setText("앵~");
}
});
}
}.start();
}
}
package com.example.i310_54.myapplication08;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void f1(View view) {
new Thread() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Button btn1 = findViewById(R.id.b);
try {
sleep(3000); // 3초 후 버튼 Text 바뀜
btn1.setText("newText");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
}.start();
}
}
'Android Studio' 카테고리의 다른 글
AsyncTask (0) | 2018.12.14 |
---|---|
Menu (0) | 2018.02.07 |
My xml (0) | 2018.02.06 |
Customizing (0) | 2018.02.06 |
OnTouch (0) | 2018.02.06 |