gpt4 book ai didi

android - Cross Walk XWalkView 的父类(super class) Views 方法没有被调用。例如onScrollChanged

转载 作者:行者123 更新时间:2023-11-29 01:32:45 28 4
gpt4 key购买 nike

我们尝试处理 Cross Walk XWalkView 版本 12.41.296.9-x86 的滚动事件,但未调用滚动。

    public class CustomXWalkView extends XWalkView{

public CustomXWalkView(Context arg0, Activity arg1) {
super(arg0, arg1);
}

public CustomXWalkView (Context context, AttributeSet attrs) {
super(context, attrs);
}



@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
Log.d("I'm scrolling", "do");
}
}

我如何获得 onScrollChanged 事件是 XWalkView。

最佳答案

下面的自定义 Web View 解决了我的问题。希望对你有帮助

package com.example.crosswalkexample;

import org.chromium.content.browser.ContentViewCore;
import org.xwalk.core.XWalkView;
import org.xwalk.core.internal.XWalkViewBridge;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;

public class CustomCrossWalkView extends XWalkView implements ContentViewCore.InternalAccessDelegate {


private XWalkViewBridge mWalkViewBridge;
private ContentViewCore mContentViewCore;

public CustomCrossWalkView(Context context, Activity arg1) {
super(context, arg1);
init();
}

public CustomCrossWalkView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}

private void init(){
if(this.getChildCount() > 0){
mWalkViewBridge = (XWalkViewBridge) this.getChildAt(0);
}else{
throw new Error("XWalkWebView Bridge not found");
}
mContentViewCore = mWalkViewBridge.getXWalkContentForTest();
mContentViewCore.setContainerViewInternals(this);
}

@Override
public boolean super_awakenScrollBars(int arg0, boolean arg1) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean super_dispatchKeyEvent(KeyEvent arg0) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean super_dispatchKeyEventPreIme(KeyEvent arg0) {
// TODO Auto-generated method stub
return false;
}

@Override
public void super_onConfigurationChanged(Configuration arg0) {
// TODO Auto-generated method stub

}

@Override
public boolean super_onGenericMotionEvent(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean super_onKeyUp(int arg0, KeyEvent arg1) {
// TODO Auto-generated method stub
return false;
}


@Override
public boolean awakenScrollBars() {
// TODO Auto-generated method stub
return super.awakenScrollBars();
}

@Override
public boolean drawChild(Canvas canvas, View child, long drawingTime) {
// TODO Auto-generated method stub
return super.drawChild(canvas, child, drawingTime);
}

@Override
public void onScrollChanged(int l, int t, int oldl, int oldt) {
// TODO Auto-generated method stub
Log.d("onScrollChanged", "Scorlling");
super.onScrollChanged(l, t, oldl, oldt);
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
// TODO Auto-generated method stub
return super.dispatchTouchEvent(ev);
}


}

关于android - Cross Walk XWalkView 的父类(super class) Views 方法没有被调用。例如onScrollChanged,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30315990/

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