ProgressDialog를 실행하는 데 실제 문제가 있습니다. 내 코드 : 그 다음은Android : ProgressDialog 실패
ProgressDialog dialog;
try {
dialog = new ProgressDialog(context);
dialog.setCancelable(true);
dialog.setMessage("Loading ...");
// set the progress to be horizontal
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
// set the bar to the default value of 0
dialog.setProgress(0);
// set the maximum value
dialog.setMax(100);
// display the progressbar
dialog.show();
}
catch (Exception e1)
{
e1.printStackTrace();
}
나는 몇 가지 물건을로드하고 진행률 표시 줄을 업데이트 내 배경 스레드를 만들 수 있지만, 멀리 것을 얻을 수 없다. 스택 추적에서 "창을 추가 할 수 없습니다 - 응용 프로그램에 대한 토큰 null이 아닙니다."대화 상자가 디버거에서 모든 올바른 작업을 수행 할 것으로 보이지만 null이 아닙니다. 오류.
아무에게도 빛을 비출 수 있습니까?
죄송합니다. @Janusz 저는 (멍청한 놈) 무슨 뜻인지 확실하지 않습니다. 전달하는 컨텍스트는 다음과 같습니다. Context context = getApplicationContext(); - 활동에 대한 참조를 전달하는 것이 무슨 뜻인지 잘 모르겠습니다. 무슨 뜻인지 보여주는 코드 줄 줄래? 많은 감사합니다. – Barry
내 게시물을 편집 예 – Janusz
+1 getApplicationContext()를 사용하면 대화 상자를 표시 할 때 FC가 발생합니다. – dymmeh