title: Adding OnTouchListener to each line of ListView in ListFragment
body: <p>Actually I thought the <code>ListView</code> of a ListFragment would have been created in <code>OnActivityCreated</code>.</p>
  
  <pre><code>  @Override
      public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
  
          ...initialize the namesList
  
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getActivity(),
          android.R.layout.simple_list_item_1, namesList);
      setListAdapter(adapter);
  
      }
  </code></pre>
  
  <p>Then I access the <code>ListView</code> in <code>onResume</code> to add a <code>OnTouchListener</code> to each row in the list (=the children) However there are no children added to the ListView yet - even though they should be due to the code above in <code>onActivityCreated</code> one should expect.</p>
  
  <pre><code>  @Override
      public void onResume() {
      super.onResume();
      ListView lv = getListView();
      int n1 = lv.getChildCount();
      for (int ii = 0; ii &lt; n1; ii++) {
          View lineV = lv.getChildAt(ii);
          lineV.setOnTouchListener(new MyTouchListener());
      }
  
      }
  </code></pre>
  
  <p>So the last chance to add the OnTouchListener is in <code>OnListItemClick</code>. (since there are no children in the ListView before)</p>
  
  <pre><code>   @Override
      public void onListItemClick(ListView l, View v, int position, long id) {
      v.setPressed(false);
  
      ListView lv = getListView();
      int n1 = lv.getChildCount();
      for (int ii = 0; ii &lt; n1; ii++) {
          View lineV = lv.getChildAt(ii);
          lineV.setOnTouchListener(new MyTouchListener());
      }
  
      }
  </code></pre>
  
  <p>But even here the <code>OnTouchListeners</code>  have still not been added to the displayed lines.</p>
  
  <p>Only after couple of times touching some lines in the displayed names list finally the <code>OnTouchListener</code> have been added and intercept the touches.</p>
  
  <p>But until then the normal <code>onListItemClick</code> catches the touches - which I just don't want to happen.</p>
  
  <p>All I need is to add the <code>OnTouchListeners</code> to each line in a <code>ListView</code> from THE VERY BEGINNING when the list is displayed so I can do whatever I want instead of let the <code>OnListItemClick</code> handle the event.</p>
  
  <p>(I actually want to drag the line around while pressing the line - <code>OnListItemClick</code> only starts AFTER the line has been untouched)</p>
  
  <p>Many thanks!</p>