问题
I would like to have a Toast Message appear while my app is downloading information but even if I put it before my code it doesn't appear until after the download has completed. Putting my code in a separate thread causes many headaches but putting toast in a separate thread doesn't work either. Is there anyway I can have this Toast message come up before this or am I just going to have to work through the headaches?
回答1:
You should be putting asynchronous downloads in a separate thread anyway, so as to not disable the main thread's UI. When you call a blocking I/O method, the UI will not respond.
Check out this documentation on Handling Expensive Operation in the UI Thread.
回答2:
As magaio already said you should use another thread for downloading stuff. My two cents:
- use progress dialog instead of Toast so User can actually see the process
- Use AsyncTask for download to update progress so user can actually see the progress
来源:https://stackoverflow.com/questions/3747850/toast-immediately