Toast Immediately

ⅰ亾dé卋堺 提交于 2019-12-11 12:32:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!