gpt4 book ai didi

android - java.lang.NoClassDefFoundError : Could not initialize class android. View .GestureDetector

转载 作者:行者123 更新时间:2023-11-30 03:34:26 25 4
gpt4 key购买 nike

我在尝试初始化水平 ScrollView 类时遇到此错误:

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);
}

错误被追溯到这一行:

mGesture = new GestureDetector(getContext(), mOnGesture);

mGesture 是私有(private) GestureDetector:

private GestureDetector mGesture;

my UI

最佳答案

无论如何在编辑模式下你都不需要它,所以按照提示去做:

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是否为null。

关于android - java.lang.NoClassDefFoundError : Could not initialize class android. View .GestureDetector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16856497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com