Android-加载片段实现 [英] Android - Loading fragment implementation

查看:76
本文介绍了Android-加载片段实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启动我的应用并立即显示主屏幕.屏幕上一半的信息将从本地存储中加载,另一半来自Web服务.这些将分别位于两个不同的片段上.我想在从Web服务获取数据时显示一个加载不确定的进度条,类似于Google Play商店加载应用的日期的方式,如下所示的两个状态所示:

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:

通过进度条&加载片段.普通屏幕(隐藏)在一种布局中.收集到来自Web服务的数据后,请填充正常屏幕,然后隐藏包含进度条的视图组并显示包含数据的视图组.

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?

谢谢.

推荐答案

您可以自己实现它,但也可以使用名为

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

这篇关于Android-加载片段实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆