启动画面期间加载MainActivity [英] Load MainActivity during Splash Screen

查看:83
本文介绍了启动画面期间加载MainActivity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个 splashScreenActivity ,要求用户按下按钮进入 MainActivity .

I currently have a splashScreenActivity that requires the User the press on a button to go to the MainActivity.

是否可以加载 MainActivity 的所有内容,而没有 MainActivity 的UI出现在 splashScreenActivity 的顶部用户界面,以便当他确实按下按钮时将其重定向到 MainActivity ,并且所有数据都已100%加载?

Would it be possible to load all the contents of MainActivity WITHOUT MainActivity's UI APPEARING ON TOP OF splashScreenActivity's UI so that when he does presses the button, he is redirected to the MainActivity and all the data is 100% loaded?

预先感谢

推荐答案

我找到了解决我问题的方法!

I found an answer to my problem!

请注意,就我而言, MainActivity 可以是任何活动

Note that in my case MainActivity can be any activity

将启动画面作为 fragment 而不是 activity ,使您可以将 MainActivity fragment ,而 MainActivity 数据会在后台加载.

Having a Splash Screen as a fragment instead of an activity allows you to overlay the MainActivity with the fragment, while the MainActivity data loads in the background.

此时,只要准备就绪,只需将 fragment 的可见性设置为 View.GONE 或将其从片段堆栈中弹出 getFragmentManager().popBackStack(); ,然后您将(永远不会离开)返回到加载所有数据的 MainActivity .

At this point, whenever you are ready, simply set the visibility of the fragment to View.GONE or pop it off the fragment stack getFragmentManager().popBackStack();, and you will return (never really left) to your MainActivity with all the data loaded.

这篇关于启动画面期间加载MainActivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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