Java – the title of the Google bottomnavigationview project disappears after several quick tabs

activity_ main. In XML:

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:elevation="4dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="1.0"
    />

bottom_ bar. xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
    android:id="@+id/tab_addcard"
    android:enabled="true"
    android:title="@string/addcard"
    android:icon="@drawable/ic_tabicon_addcard"
    app:showAsAction="ifRoom|withText"/>
<item
    android:id="@+id/tab_approvals"
    android:enabled="true"
    android:title="@string/approvals"
    android:icon="@drawable/ic_tabicon_approvals"
    app:showAsAction="always|withText"/>
<item
    android:id="@+id/tab_mycard"
    android:enabled="true"
    android:title="@string/mycard"
    android:icon="@drawable/ic_tabicon_mycard"
    app:showAsAction="always|withText"/>

MainActivity. java:

BottomNavigationView bottombar;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    bottombar= (BottomNavigationView) findViewById(R.id.bottom_navigation);

    bottombar.inflateMenu(R.menu.bottom_bar);
}

My problem is: after initializing the bottom bar and adding all the contents of the project Once I run it and quickly (very quickly) try to switch between the project tabs in the bottom Navigation view, suddenly the project title text disappears Can anyone suggest a solution?

Solution

Setonnavigationitemselectedlistener should return false instead of true

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>