Android WebView inside ListView onclick event issues

前端 未结 6 1203
太阳男子
太阳男子 2020-12-25 09:03

I have a ListView where each row has two webviews side by side, taking up the entire row. I\'ve set up onListItemClick() in my ListActivity, but they are not fired when I ta

6条回答
  •  半阙折子戏
    2020-12-25 09:12

    Got it working in Android 4.4 using the same approach as bjdodson above but also overriding dispatchTouchEvent

    public class NonClickableWebview extends WebView {
        public NonClickableWebview(Context context, AttributeSet attrs) {
            super(context, attrs);
            setClickable(false);
            setLongClickable(false);
            setFocusable(false);
            setFocusableInTouchMode(false);
        }
        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
            return false;
        }
    }
    

提交回复
热议问题