ibrahimsn98 / SmoothBottomBar

A lightweight Android material bottom navigation bar library
MIT License
1.97k stars 255 forks source link

Using occur when I try to use SmoothBottomBar to open an Activity #89

Closed cychancw closed 3 years ago

cychancw commented 3 years ago

I saw the sample and use the code below successfully to do what I meant to do. However, when I launch the activity by the SmoothBottomBar, it jumps back to the start Destination(home_fragment) first and then start the activity that I want. It looks very bad. Why would this happen? Anything I can do to solve this?

`<fragment android:id="@+id/home_fragment" android:name="com.example.home_Fragment" android:label="Home" tools:layout="@layout/fragment_home"> <action android:id="@+id/action_firstFragment_to_secondFragment" app:destination="@id/two_fragment" />

<fragment android:id="@+id/two_fragment" android:name="com.example.two_Fragment" android:label="two" tools:layout="@layout/fragment_two"

>
<action
    android:id="@+id/action_secondFragment_to_activity"
    app:destination="@id/ai_activity" />

<activity android:id="@+id/my_activity" android:name="com.example.myActivity" android:label="My" tools:layout="@layout/activity_my" >

<fragment android:id="@+id/my_fragment" android:name="com.example.my_Fragment" android:label="User" tools:layout="@layout/fragment_my" />`

cychancw commented 3 years ago

Haha I solved it in a weird way.

@Override protected void onPause() { super.onPause(); smoothBottomBar.setItemActiveIndex(2); // The index of my activity }

cychancw commented 3 years ago

Actually It still back to start Destination (home_Fragment)