package com.androidside.handlerdemoa1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
//사용자 화면이 멈추는 현상이 발생함
public class Main extends Activity {
TextView text;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text = (TextView) findViewById(R.id.text);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
doit();
}
});
Button button2 = (Button) findViewById(R.id.button2);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(Main.this, "테스트 버튼이 클릭되었습니다.",
Toast.LENGTH_SHORT).show();
}
});
}
private void doit() {
// 0.1초씩 대기하면서 100번 카운트(총 10초 동안 실행됨)
for (int i = 1; i <= 100; i++) {
try {
text.setText("" + i);
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}
}
'IT 연구회' 카테고리의 다른 글
Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace. (1) | 2013.12.23 |
---|---|
이중 스크롤뷰(ScrollView)의 scroll 컨트롤하기 (0) | 2013.09.17 |
용량이 1MB가 넘는 파일을 asset에 담을 때 (0) | 2013.09.17 |
인텐트 (Intent) (0) | 2013.09.17 |
webview (0) | 2013.09.17 |
안드로이드 스레드2 핸들러(handler) (0) | 2013.09.17 |
listview (0) | 2013.09.17 |
listview 2 (0) | 2013.09.17 |
listview3 (0) | 2013.09.17 |
listview layout xml (0) | 2013.09.17 |