protected void onResume() {
this.overridePendingTransition(0, 0);
super.onResume();
Thread thread = new Thread(new Runnable(){
@Override
public void run(){
try{
Thread.sleep(100);
} catch (Exception e){
e.printStackTrace();
}
runOnUiThread(new Runnable(){
@Override
public void run() {
try{
Thread.sleep(100);
} catch (Exception e){
e.printStackTrace();
}
final TextView timertxt01 = (TextView) findViewById(R.id.TimerView01);
final TextView timertxt02 = (TextView) findViewById(R.id.TimerView02);
Calendar c = Calendar.getInstance();
final int Year = c.get(Calendar.YEAR);
int Month = c.get(Calendar.MONTH); // 1월(0), 2월(1)...
int Day = c.get(Calendar.DAY_OF_MONTH);
final int DayOfWeek = c.get(Calendar.DAY_OF_MONTH); // 일요일(1), 월요일(2)...
int Hour = c.get(Calendar.HOUR_OF_DAY); // HOUR는 12시간, HOUR_OF_DAY는 24시간
int Minute = c.get(Calendar.MINUTE);
final int Second = c.get(Calendar.SECOND);
final int AmPm = c.get(Calendar.AM_PM); // AM(0), PM(1)
String stringDayOfWeek[] = {"", "일", "월", "화", "수", "목", "금", "토"};
String stringAmPm[] = {"오전", "오후"};
Month = Month+1;
String str_Month = "";
String str_Day = "";
String str_Hour = "";
String str_Minute = "";
if (Month < 10){
str_Month = "0";
} else {
str_Month = "";
}
if (Day < 10){
str_Day = "0";
} else {
str_Day = "";
}
if (Hour < 10){
str_Hour = "0";
} else {
str_Hour = "";
}
if (Minute < 10){
str_Minute = "0";
} else {
str_Minute = "";
}
timertxt01.setText(Year + "." + str_Month + Month + "." + str_Day + Day);
timertxt02.setText(str_Hour + Hour + " : " + str_Minute + Minute);
}
});
}
});
thread.start();
}
이 소스를 넣어놓으면 일단 처음 실행시에 실행(TextView에 현재 시간 넣어주는것)이 됩니다.
그런데 한번만 실행되고 그 후론 실행이 안되네요.
소스에 틀린 부분이나, 추가해야할 부분 있으면 알려주세요.