search

Home  >  Q&A  >  body text

android 网络加载中提示

android程序执行网络操作时, 弹出圆形进度条,显示加载中,连接完成后就消失。
这是怎么实现的?

PHPzPHPz2773 days ago805

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 13:17:41

    Generally speaking, network operations are placed in asynchronous threads and can be implemented by inheriting the AsyncTask class.
    - Place network operations in the doInBackground method of this class
    - Before calling the network operation, the onPreExecute method inside will be called, and the progress bar can be displayed here
    - After performing the network operation, the onPostExecute method of this class will be called, and the progress bar will be hidden here.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:17:41

    First of all, I agree with the method above. Let me provide the second method:
    It can also be achieved using handler, but the premise is that you must be able to customize the dialog control. You only need to display the dialog control before the network task execution starts. , after completion, just dismiss and adjust the dialog in the handleMessage() method.

    reply
    0
  • Cancelreply