Android - Loading fragment implementation

别说谁变了你拦得住时间么 提交于 2019-12-21 09:07:21

问题


I'd like to start my app and show the main screen instantly. Half of the info on the screen will be loaded form local storage and the other half will be from a web service. Each of these will be on two different fragments. I'd like to display a loading indeterminate progress bar while the data is being fetch from the webservice, similar to how the Google Play Store loads it's app date as shown below by the two states below:

My thoughts on implementing it are as follows:

Load the fragment in with the progress bar & the normal screen (hidden) in one layout. Once the data from the web service has been collected, populate the normal screen, then hide the view group containing the progress bar and show the viewgroup with the data.

Is this best practice? Are the better ways to do it than this?

Thanks in advance.


回答1:


You can implement it yourself but you can also use a simple library called ProgressFragment avalaible on github



来源:https://stackoverflow.com/questions/19855020/android-loading-fragment-implementation

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