4
파일 다운로드가 완료 될 때까지 내 토스트가 표시되지 않습니다 (다운로드 기능에 주석을 달았습니다). 어떤 아이디어?내 토스트가 왜 나타나지 않습니까?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView main_image_view = (ImageView)this.findViewById(R.id.main_image_view);
TextView text_view = (TextView)this.findViewById(R.id.main_text_view);
Context context = getApplicationContext();
CharSequence text = "File Not Found. Downloading... Please be patient, it's a large file!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
// This function fetches a file from a URL.
brain = get_frame_fl(file_name, mActive_slice);
brain_slice = Bitmap.createBitmap(brain_pixels, frame_width, frame_height, Bitmap.Config.ARGB_8888);
// display
main_image_view.setImageBitmap(brain_slice);
}
참으로. 'AsyncTask'의 예를 보려면이 대답을보십시오 : http://stackoverflow.com/questions/4828676/preventing-internet-accessing-method-from-delaying-a-toast-popup/4829593#4829593 – binnyb
또는 스레딩,하지만 AsyncTask는이 문제에 대한보다 쉬운 접근 방법입니다. – prolink007
환상적입니다. 고맙습니다. 그리고 binnyb를 참조 해 주셔서 감사합니다. –