在这里,我有一个带有 setOnTouchListener 的 ViewFlipper 可以正常工作。然后我为 ReLayNewsItem 充气,然后将其添加到 ViewFlipper。
现在我希望 WebView (web) 监听触摸事件并将它们传递给 ViewFlipper。
final ViewFlipper VFnewsFeed = new ViewFlipper(this);
VFnewsFeed.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetectorLR.onTouchEvent(event)) { return true; }
else { return true; }
}});
///////////////////
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout ReLayNewsItem = (RelativeLayout) inflater.inflate(R.layout.newsitem, null);
final WebView web = (WebView)ReLayNewsItem.findViewById(R.id.NewsItemWv);
web.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
VFnewsFeed.dispatchTouchEvent(event); /// ERROR HERE!
return false;
}});
然而它给了我这个——
07-14 21:12:43.600: E/AndroidRuntime(14048): FATAL EXCEPTION: main
07-14 21:12:43.600: E/AndroidRuntime(14048): java.lang.StackOverflowError
07-14 21:12:43.600: E/AndroidRuntime(14048): at life.iface.main$11.onTouch(main.java:1289)
07-14 21:12:43.600: E/AndroidRuntime(14048): at android.view.View.dispatchTouchEvent(View.java:4605)
07-14 21:12:43.600: E/AndroidRuntime(14048): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1518)
07-14 21:12:43.600: E/AndroidRuntime(14048): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
...
有任何想法吗?谢谢!;)