最近实现了一个ViewPager滑动的效果,但是意外的发现,在ViewPager里面如果有WebView控件,里面的内容是可以Mark的
但是在Mark时如果第一次操作是横向的Mark,在Mark两个字符左右的时候ViewPager就会响应中断然后横向滑动,这让人情何以堪啊~~
折腾了一会儿,最后整个反射然后重写中断方法在2.3上解决了,但是API 15+发现有时候Mark不上,实在搞不定了,先放着吧
public class XXXXXPager extends ViewPager { public XXXXXPager(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override public boolean onInterceptTouchEvent(MotionEvent arg0) { // TODO Auto-generated method stub boolean touchSelection = false; requestFocus(); if (getFocusedChild() != null) { WebView mWebView = (WebView) getFocusedChild().findViewById( R.id.webview); if (mWebView != null) { Class<?> webViewClass = mWebView.getClass(); try { Field selectionField = webViewClass .getDeclaredField("mSelectingText"); if (selectionField != null) { selectionField.setAccessible(true); touchSelection = selectionField.getBoolean(mWebView); } } catch (SecurityException e1) { e1.printStackTrace(); } catch (NoSuchFieldException e1) { e1.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { // touchSelection = false; } } } if (touchSelection) { return false;// false } else { return super.onInterceptTouchEvent(arg0); } } }