user5985727 user5985727 - 1 month ago 8
Android Question

Cant find specific ID - Android Java

Hi guy I´m using the roughike Bottombar and I want to create a OnTabSelectedListener with 5 different Tabs. Currently it´s working with 3 different Tabs but when I want to add a 4 or 5 tab I cant find the speciffic ID of the Tab.

My code looks like this right now:

bbMainNavigation.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes int tabId) {
Fragment fMainContent = null;

if (tabId == R.id.tBarFriends) {
cMainFragment = FriendsFragment.class;
} else if (tabId == R.id.tBarMessage) {
cMainFragment = MessagesFragment.class;
} else if (tabId == R.id.tBarRadar) {
cMainFragment = RadarFragment.class;
} else if (tabId == R.id.tBarAccount){
cMainFragment = AccountFragment.class;
}


My xml with the Tabs looks like that:

<?xml version="1.0" encoding="utf-8"?>




<resources>

<tabs>

<tab
icon="@drawable/friends"
id="@+id/tBarFriends"
title="Friends" />

<tab
icon="@drawable/message"
id="@+id/tBarMessage"
title="Message" />

<tab
icon="@drawable/radar"
id="@+id/tBarRadar"
title="Radar" />

<tab
icon="@drawable/account"
id="+@id/tBarAccount"
title="Account" />

<tab
icon="@drawable/settings"
id="+@id/tab_settings"
title="Settings" />
</tabs>

</resources>




If I try to run the code I get the following error:


Error:(40, 41) error: cannot find symbol variable tBarAccount


I hope you guys can help me

Answer
    <tab
        icon="@drawable/account"
        id="@+id/tBarAccount"         <<'+' must be after '@'
        title="Account" />

    <tab
        icon="@drawable/settings"
        id="@+id/tab_settings"        <<'+' must be after '@'
        title="Settings" />