BottomBar icon indicating copy to clipboard operation
BottomBar copied to clipboard

Opening tab B from tab A does not set tab B as the active tab

Open wangerekaharun opened this issue 7 years ago • 4 comments

Am having this issue when I open tab B from tab A it does not set tab B as the active tab.This is making the fragment have two instances.On clicking the tab B from the bottom bar,it has no data but when i go back and open tab B from tab A again..it displays data please help out.

wangerekaharun avatar Jul 26 '17 09:07 wangerekaharun

I quit didn't get your question, but based on the title I created a workaround. It will be a good feature in the future if this option will be implemented, but for now, you can make something like this.

In your activity, override the onBackPressed method:

@Override
public void onBackPressed()
{
    super.onBackPressed();

    /* I suppose you use fragments, so we create a method called setCorrectTabPosition, that will take
        the current fragment name.
    */
    setCorrectTabPosition(getFragmentManager().findFragmentById(Your main container ID).getClass().getSimpleName());
}

Now we implement our setCorrectTabPosition method: `

private void setCorrectTabPosition(String shownFragmentName)
{
    if(shownFragmentName.equals("FIRST FRAGMENT NAME"))
        bottomBar.setDefaultTabPosition(0);

    else if(shownFragmentName.equals("SECOND FRAGMENT NAME"))
        bottomBar.setDefaultTabPosition(1);

    //So you continue, depending on how many fragments you have.
}

`

That's it, a simple workaround to set your bottombar showing good position.

EdvinM avatar Jul 31 '17 22:07 EdvinM

@EdvinM Thanks for the simple workaround and i get it very clearly....my situation is i have a button in a frsgment lets say A..which when on clicked it opens fragment B and starts to record time. So the problem occurs when i open Fragment B on its bottom bar position...it indicates no record has been taken and this is creating a second instance of the same fragment

wangerekaharun avatar Aug 01 '17 06:08 wangerekaharun

@wangerekaharun how do you open tab B from Tab A ??

tao101 avatar Aug 06 '17 02:08 tao101

@tao101 i have a button in Tab A which when clicked goes to fragment in Tab B

wangerekaharun avatar Aug 23 '17 12:08 wangerekaharun