本文介绍了java.lang.NoClassDefFoundError:无法初始化类android.view.GestureDetector的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试初始化水平滚动视图类时,我收到此错误:
I am getting this error when trying to initialize a horizontal scroll view class:
java.lang.NoClassDefFoundError: Could not initialize class android.view.GestureDetector
private synchronized void initView() {
mLeftViewIndex = -1;
mRightViewIndex = 0;
mDisplayOffset = 0;
mCurrentX = 0;
mNextX = 0;
mMaxX = Integer.MAX_VALUE;
mScroller = new Scroller(getContext());
mGesture = new GestureDetector(getContext(), mOnGesture);
}
错误正在追溯到这一行:
the error is being traced back to this line:
mGesture = new GestureDetector(getContext(), mOnGesture);
mGesture是一个私人GestureDetector:
mGesture is a private GestureDetector:
private GestureDetector mGesture;
推荐答案
在编辑模式下,您不需要它,所以提示说:
You don't need it when in edit mode anyway, so do as the tip says:
private synchronized void initView() {
mLeftViewIndex = -1;
mRightViewIndex = 0;
mDisplayOffset = 0;
mCurrentX = 0;
mNextX = 0;
mMaxX = Integer.MAX_VALUE;
if (!this.isInEditMode()) {
mScroller = new Scroller(getContext());
mGesture = new GestureDetector(getContext(), mOnGesture);
}
}
然后检查mGesture和mCcroller在使用前的代码。
And then check for mGesture and mCcroller being null in the code before using.
这篇关于java.lang.NoClassDefFoundError:无法初始化类android.view.GestureDetector的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!