이 메서드는 Activity가 아닌 RecordTable 클래스에 정의합니다.
주 UI 스레드에서 호출하고 유효한 UI 스레드 컨텍스트를 매개 변수로 전달합니다.
물론, 그것은 메시지와 함께 작동하지 않습니다 내가 다른 포스트에서 본
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
Android UI 스레드에없는 클래스에서 진행 대화 상자 표시
그들은 대신 new thread
의 runOnUiThread
을 사용하는 것이 좋습니다하지만 클래스가 아니므로 활동 runOnUiThread
사용할 수 없습니다.
실행 가능 영역 밖에서 대화 상자를 시작하는 방법()도 작동하지 않습니다.
누구든지이 문제를 발견하고 해결 방법을 찾았습니까?
public synchronized void scrollUp(final Context context, final ArrayList<Record> list, final int count) {
new Thread(new Runnable() {
public void run() {
setScrolling(true);
ProgressDialog pd = ProgressDialog.show(context, "", context.getResources().getString(R.string.loading_msg), true);
int n = Math.max(mViewStartIndex - count, 0);
for(int i = mViewStartIndex - 1; i >= n; i--) {
RecordTable.this.addFirstRow(list.get(i));
RecordTable.this.removeViews(RecordTable.this.getChildCount() - 1, 1);
}
pd.dismiss();
setScrolling(false);
}
}).start();
}
당신은 context.runOnUiThread (새로운 Runnable (etc ..))를 시도 했습니까? –
@ MuratNafiz 방금 시도한 'runOnUiThread'는'context'에서 사용할 수 없습니다. – ilomambo
당신의 컨텍스트를 자신의 Activity로 전송할 수 있습니다. 예 : ((YourActivityName) context) .runOnUiThread (new Runnable() ... 여기서 'YourActivityName'은 컨텍스트를 전달하는 작업입니다. –