由于fragment是存在于activity之中的,所以触摸事件会被activity首先得到。

为了在fragment中执行ontouch方法,需要做如下处理:

  1. mFragment = new TabelFragment();  
  2.                 View view = (View)findViewById(R.id.main_item_details);  
  3.                 view.setOnTouchListener((TabelFragment)mFragment);  
  4.                 ft.add(R.id.main_item_details, mFragment,  
  5.                         FragmentInfo.FRAGMENT_TABEL_TAG);  

fragment需要实现OnTouchListener接口即可。

相关文章:

  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-11
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
相关资源
相似解决方案