Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – com.google.android.material.bottomnavigation.BottomNavigationView not displaying any content

Posted on November 11, 2022 By

Solution 1 :

Your Activity works? I miss the code for onCreate()!

Please add an id for the BottomNavigationView e.g.:

<com.google.android.material.bottomnavigation.BottomNavigationView
    android_id="@+id/navigation"
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_layout_gravity="bottom"
    android_background="?android:attr/windowBackground"
    app_menu="@menu/navigation" />

In your Activity must be code like this. Is it there?

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    BottomNavigationView navigation = findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener( mOnNavigationItemSelectedListener);
}
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
        = new BottomNavigationView.OnNavigationItemSelectedListener() {

    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
             // ... implement code here
        }
        return false;
    }

};

Edit: are the icons (e.g. ic_home_black_24dp, see picture) in the drawable folder and shown in Android Studio when displaying menu.xml?
enter image description here

Solution 2 :

i found the answer here:

Rendering Issue in Android Studio

seems it was a rendering issue with the theme and had to change to appcompat.

thank you

Problem :

I’m trying to make a bottom Nav using android studio, but it will not display. if I add height to it, I can see the BG color but still no content of the menu items

EDIT:
its treating the menu xml as empty.

here is my code, ive also tried changing the layout to linear, frame and constraint:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 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=".HomeScreen">



    <com.google.android.material.bottomnavigation.BottomNavigationView
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        app_menu="@menu/menu"
    android_layout_alignParentBottom="true"
        android_background="@color/btnSignUp"/>
    </RelativeLayout>

here is my menu item, its located in a menu folder

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

    <item
        android_id="@+id/nav_home"
        android_icon="@drawable/ic_home_black_24dp"
        android_title="Home"
        />

    <item
        android_id="@+id/nav_search"
        android_icon="@drawable/ic_search_black_24dp"
        android_title="Search"
        />

    <item
        android_id="@+id/nav_orders"
        android_icon="@drawable/ic_receipt_black_24dp"
        android_title="Orders"
        />

    <item
        android_id="@+id/nav_account"
        android_icon="@drawable/ic_person_black_24dp"
        android_title="My Account"
        />

</menu>

and lastly my dependencies:

implementation 'com.github.jd-alexander:android-flat-button:1.1'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-firestore:21.4.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-database:19.2.1'
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.android.material:material:1.1.0'

Comments

Comment posted by M123

Did you solve this problem ?

READ  [FIXED] Unable to fetch data from Custom Adaptor in android
Powered by Inline Related Posts

Comment posted by Emil C.

i’ve tried it but it still wont display anything. i think its treating the menu xml as empty

Comment posted by Cor

are the icons (e.g. ic_home_black_24dp) in the drawable folder and shown in Android Studio when displaying menu.xml?

Android Tags:android, android-studio, bottomnavigationview, java

Post navigation

Previous Post: [FIXED] java – The Android LoaderManager is deprecated. Now what?
Next Post: [FIXED] android – Is WorkManager the right solution for me?

Related Posts

[FIXED] android – How to show all checkboxes in recyclerview? Android
[FIXED] not working scrollToPosition recyclerview in android Android
[FIXED] Webrtc does not generate TCP ICEs, only UDP on Android Android
[FIXED] android – Different Page heights in pageview flutter | is there a way to get overflow value Android
[FIXED] android – apk not generated because of error in dependency Android
[FIXED] android – Play Store rejecting app bundle for required automotive feature, but the feature is not marked as required in manifest Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme