我正在尝试使用具有全屏/普通视图的片段来实现照片查看器。在此处查看带有活动的 API 示例: https ://android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/view/ContentBrowserActivity.java
但我注意到 android 版本 <honeycomb. 当我在我的片段中实现 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)