简体   繁体   English

第一次启动我的应用程序时片段没有显示

[英]Fragment showing nothing when starting my app for first time

I have an app with bottom navigation fragment activity I have placed text views and buttons on my home fragment.我有一个带有底部导航片段活动的应用程序我在我的主页片段上放置了文本视图和按钮。 further these fragments are placed in a frame layout.此外,这些片段被放置在框架布局中。 when I launch my app my home fragment shows nothing just blank screen it loads everything when I switch between fragments.当我启动我的应用程序时,我的主片段只显示空白屏幕,当我在片段之间切换时它会加载所有内容。

I want to fix this, so that when I launch my app everything that is on my home fragment shows up.我想解决这个问题,这样当我启动我的应用程序时,我的家庭片段上的所有内容都会显示出来。

"

because you didn't specify the first fragment to show,因为您没有指定要显示的第一个片段,

in the onCreate you have to do this :在 onCreate 你必须这样做:

first checked the bottomNavigation item, that you want to start with :首先检查要开始的bottomNavigation项目:

 bottomNavigation.getMenu().findItem(R.id.item).setChecked(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM