我正在尝试使用具有全屏/普通视图的片段来实现照片查看器。 请参阅此处的活动API示例: https://android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/view/ContentBrowserActivity.java
但我注意到Android版本上的一个奇怪的错误<蜂窝。 当我在片段中实现OnSystemUiVisibilityChangeListener时,应用程序与NoClassDefFoundError崩溃。在android 4上一切正常。 这个错误有解决方法吗?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
PhotoViewPager viewPager = new PhotoViewPager(getActivity());
viewPager.setTag("photoViewPager");
viewPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
int diff = mLastSystemUiVis ^ visibility;
mLastSystemUiVis = visibility;
if ((diff & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0
&& (visibility & View.SYSTEM_UI_FLAG_LOW_PROFILE) == 0) {
setNavVisibility(true);
}
}
});
return viewPager;
}
堆栈跟踪
ERROR/AndroidRuntime(12708): FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.ex.android.main.photos.photo.PhotoFragment$2
at com.ex.android.main.photos.photo.PhotoFragment.onCreateView(PhotoFragment.java:87)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)