从视图寻呼机更改活动
希望你们一切都好并且安全。
我需要你的天才帮助,在下面解释我的问题:
我有 2 个活动,一个活动有五个片段的底部导航,每个片段都有 viewpager 包含至少 2 个片段,每个片段都有 recyclerview。底部导航片段在 FragmentContainerView 中打开每个回收器视图使用notifyDataSetChanged 每2 秒更新一次列表数据。另一方面,第二个活动由 viewpager 组成,viewpager 由 3 个片段和一个底部工作表组成,其底部工作表活动本身具有可运行项和处理程序更新值。
我的问题是,当我尝试从第一个活动打开第二个活动时,打开时间太长。请帮忙,如果你们可以的话..我将非常感谢你们............
Hope you all are doing well and safe.
I am in need of your genius help, explaining my problem below:
I have 2 activities, one activity is having bottom navigation of five fragments, each fragments have viewpager consist on atleast 2 fragments and every fragments have recyclerview.Bottom navigation fragments open in FragmentContainerView each recycler view is updating list data on every 2 seconds using notifyDataSetChanged. On the other hand, 2nd activity consists of viewpager consisting of 3 fragments and a bottom sheet, its bottom sheet activty it self have runables and handler updating values.
my issue is when I try to open 2nd activity from the first activity it takes too long to open. please help, If you guys can.. I'll be very thankful to you all............
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当
onCreate()
方法中的代码过多时,活动打开时间过长。当您在 onStart() 中运行大量代码时,也会发生这种情况。默认情况下,您编写的所有代码都在同一线程上运行。这使得应用程序加载时间过长。尝试在setContentView() 之后立即在第二个 Activity 上显示 Toast。
您将看到显示的 Toast,但该 Activity 会稍后打开。这只是由于代码太多所致。您可以通过将代码放入新的Thread
中来解决该问题。像这样的东西:An activity takes too long to open when too much code is in the
onCreate()
method. This also happens when you are running a lot of code inonStart().
All the code that you write, by default, runs on the same thread. This makes the app too long to load. Try to display toast on the second activity immediately after thesetContentView().
You will see the toast shown, but the activity opens later. This is only due to so much code. You can solve the problem by putting the code in a newThread
. Something like this: