title: How to handle Touch Events on a Fragment?
body: <p>I'm building an interface where <strong>I need to process touch events</strong>. In particular I would to be able to enable them only to a confined area in a fragment.
  To better understand the problem, to respect the standards and for the goal of my application, <strong>I planned the navigation drawer, which assumes the presence of many fragment</strong> (instead of activities). An activity with touch events is implemented quite easily, on the other hand I have read on the internet that <strong>with the fragments can become a problem</strong>.</p>
  
  <p>My application, at the architectural level, is as follows: 
  - MainActivity.java 
  - NavigationDrawer.java 
  - TestFragment.java (for a single fragment now, waiting to solve the problem) </p>
  
  <p>I've not found a solution or a tutorial that explains how to do well (or how to workaround the problem). Then I ask you, simplifying the problem to just "<strong>enable a touch event in a fragment (getPressure() in this case)</strong>". Below are some pieces of code that may help to solve the problem:</p>
  
  <p><strong>TestFragment</strong></p>
  
  <pre><code>public class TestFragment extends Fragment {
      private static final String ARG_SECTION_NUMBER = "section_number";
  
      public static TestFragment newInstance(int sectionNumber) {
          TestFragment fragment = new TestFragment();
          Bundle args = new Bundle();
          args.putInt(ARG_SECTION_NUMBER, sectionNumber);
          fragment.setArguments(args);
          return fragment;
      }
  
      public TestFragment() {}
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
          return inflater.inflate(R.layout.fragment_test, container, false);
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          // Here I want to return the press value (0 to 1)
      }
  }
  </code></pre>
  
  <p>How to associate the listener to the whole fragment? And in the case of a particular area? Finally, how can I return the value of the pressure on the screen?</p>
  
  <p>Thank you so much in advice! :)</p>