I'm trying to use the NavigationView on a embedded layout and trying to "move" the layout to another contentview, but it crash has soon I remove the View from the parent with:
Attempt to invoke virtual method 'void com.mapbox.services.android.navigation.ui.v5.MultiOnClickListener.clearListeners()' on a null object reference]
I have a simple class with:
public class clsNavigationView extends CoordinatorLayout implements OnNavigationReadyCallback, MapboxMap.OnMapLongClickListener,
NavigationListener, ProgressChangeListener, InstructionListListener, SpeechAnnouncementListener,
BannerInstructionsListener, OnTrackingModeChangedListener
...
inflate(getContext(), R.layout.mapbox_activity_embedded_navigation, this);
...
The layout have
<com.mapbox.services.android.navigation.ui.v5.NavigationView
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:navigationDarkTheme="@style/NavigationViewDark"
app:navigationLightTheme="@style/NavigationViewLight"/>
I put the clsNavigationView on a static FrameLayout, I add it to my mainView on another FrameLayout.
When I change view, I remove the view with:
((FrameLayout) objFrameMap.getParent()).removeView(objFrameMap);
Do my new setContentview on my main Activity.
Then I add back my Frame into my new FrameLayout on the new Content
((FrameLayout) findViewById(R.id.layer_mapview)).addView(objFrameMap);
It crash at the removeView, what can I do for fixing that? What is the best way for "move" a NavigationView without crashing?
** I'm not using fragment.