我正在尝试在嵌入式布局上使用NavigationView,并试图将布局“移动”到另一个contentview,但是它崩溃后不久,我使用以下方法从父视图中删除了视图:
Attempt to invoke virtual method 'void com.mapbox.services.android.navigation.ui.v5.MultiOnClickListener.clearListeners()' on a null object reference]
我有一个简单的课程,
public class clsNavigationView extends CoordinatorLayout implements OnNavigationReadyCallback, MapboxMap.OnMapLongClickListener,
NavigationListener, ProgressChangeListener, InstructionListListener, SpeechAnnouncementListener,
BannerInstructionsListener, OnTrackingModeChangedListener
...
inflate(getContext(), R.layout.mapbox_activity_embedded_navigation, this);
...
布局具有
<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"/>
我将clsNavigationView放在一个静态FrameLayout上,然后将其添加到另一个FrameLayout上的mainView中。
更改视图时,我使用以下方法删除视图:
((FrameLayout) objFrameMap.getParent()).removeView(objFrameMap);
在我的主活动上执行新的setContentview。
然后我将框架重新添加到新内容上的新FrameLayout中
((FrameLayout) findViewById(R.id.layer_mapview)).addView(objFrameMap);
它在removeView上崩溃了,我该怎么解决? 在不崩溃的情况下“移动” NavigationView的最佳方法是什么?
**我没有使用片段。