从视图寻呼机更改活动

发布于 2025-01-16 01:54:43 字数 356 浏览 1 评论 0原文

希望你们一切都好并且安全。

我需要你的天才帮助,在下面解释我的问题:

我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒几许 2025-01-23 01:54:43

onCreate() 方法中的代码过多时,活动打开时间过长。当您在 onStart() 中运行大量代码时,也会发生这种情况。默认情况下,您编写的所有代码都在同一线程上运行。这使得应用程序加载时间过长。尝试在 setContentView() 之后立即在第二个 Activity 上显示 Toast。 您将看到显示的 Toast,但该 Activity 会稍后打开。这只是由于代码太多所致。您可以通过将代码放入新的Thread 中来解决该问题。像这样的东西:

Thread thread = new Thread(runnable);
thread.start();

Runnable runnable = new Runnable(){
    public void run() {   
       //enter most(not all) of your code here
    }
}; 

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 in onStart(). 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 the setContentView(). 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 new Thread. Something like this:

Thread thread = new Thread(runnable);
thread.start();

Runnable runnable = new Runnable(){
    public void run() {   
       //enter most(not all) of your code here
    }
}; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文