0
주 화면의 생성자에서 내 메서드를 실행하면 작동하지만 타이머에서 호출하면 오류가 발생합니다.타이머에서 메서드를 실행할 때 illegalstatexception을받습니다.
public void buildDesc(){
try {
JSONObject event = array.getJSONObject(currentPage);
String title = event.getString("title");
String by = event.getString("by");
String by_name = event.getString("by_name");
String summary = event.getString("summary");
int nid = event.getInt("nid");
vfm.add(new LabelField(title));
System.out.println("The Title:"+title);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
그리고 타이머 :
timer = new Timer();//Create the timer to loop the events every 5 seconds
timer.scheduleAtFixedRate(new TimerTask(){
public void run() {
currentPage++;
if(currentPage > 3){
currentPage = 0;
}
System.out.println("Page Position:"+pagePosition(currentPage+1));
gallery.setHorizontalScroll(pagePosition(currentPage));
buildDesc();
}
}, 0, 10000);
내가에하지 않으면 나는 UI 변경 내용을 적용 할 수는 없습니다, 아마도,라는 안드로이드 질문을 읽어 여기에
내 방법입니다 UIThread?