【问题标题】:The bottom and the top bar are loading each time I change the activity每次更改活动时,底部和顶部栏都会加载
【发布时间】:2018-04-15 19:32:14
【问题描述】:

我使用的是BottomNavigationViewEX,每次单击此栏的一个按钮时,整个页面都在加载,甚至底部和顶部栏。

这是我在每个活动中使用的代码:

private void setupBottomNavigationView() {
    Log.d(TAG, "setupBottomNavigationView: setting up BottomNavigationView");
    BottomNavigationViewEx bottomNavigationViewEx = (BottomNavigationViewEx) findViewById(R.id.BottomNavViewBar);
    BottomNavigationViewHelper.setupBottomNavigationView(bottomNavigationViewEx);
    BottomNavigationViewHelper.enableNavigation(HomeActivity.this, bottomNavigationViewEx);
    Menu menu = bottomNavigationViewEx.getMenu();
    MenuItem menuItem = menu.getItem(ACTIVITY_NUM);
    menuItem.setChecked(true);
}

我很确定我应该只在一个活动中设置我的底部栏,而不是每个活动,但我是 Android Studio 的初学者,所以我不确定如何实现。

感谢您的帮助,我会根据需要提供尽可能多的信息。

编辑 1:这里是 activity_popcore.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".popcore">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <!-- Top Bar -->

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/relLayout1">

        <include layout="@layout/layout_top_tabs"/>

    </RelativeLayout>

    <!-- Body -->

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/relLayout2"
        android:layout_below="@+id/relLayout1">



        <include layout="@layout/layout_center_viewpager"/>

    </RelativeLayout>

    <!-- Bottom Bar -->

    <include layout="@layout/layout_bottom_navigation_view"/>

</RelativeLayout>

这是我的 layout_bottom_navigation_view.xml :

<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true">

    <com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/BottomNavViewBar"
        android:background="@drawable/dark_grey_border_top"
        app:itemIconTint="@color/bottom_nav_item_colors"
        app:itemTextColor="@color/bottom_nav_item_colors"
        app:menu="@menu/bottom_navigation_menu">

    </com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx>

</RelativeLayout>

如果您需要更多信息,请联系我,感谢您的帮助!

【问题讨论】:

    标签: android android-layout android-studio bottomnavigationview


    【解决方案1】:

    我想问题不在这里。我相信您应该分析您的 Activity/Fragment 上的 onResume() 块以识别问题。请提供更多信息。

    【讨论】:

    • 我在帖子中添加了更多信息,希望您拥有所需的一切!谢谢你帮助我
    猜你喜欢
    • 2018-11-25
    • 1970-01-01
    • 1970-01-01
    • 2021-06-28
    • 2020-10-01
    • 2019-12-07
    • 1970-01-01
    • 2021-01-14
    • 1970-01-01
    相关资源
    最近更新 更多