title: java reference "this" from anonymous method
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/56974/keyword-for-the-outer-class-from-an-anonymous-inner-class">Keyword for the outer class from an anonymous inner class?</a>  </p>
  </blockquote>
  
  
  
  <p>My class (let's call it <code>MyClass</code>) has <code>m_listener</code> member that is used for notification purposes. There's no problem to use it from within an anonymous method:</p>
  
  <pre><code>private void myMethod(SomeObj myObj)
  {
      ...
      myObj.setOnTouchListener(new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              m_listener.myOnClick(this);
              return false;
          }
      });
      ...
  }
  </code></pre>
  
  <p>In the code <code>this</code> refers to the anonymous <code>OnTouchListener</code> instance. What should I write instead of <code>this</code> to refer to <code>MyClass</code> instance (just like <code>m_listener</code> refers to <code>MyClass.m_listener</code>, not to the <code>OnTouchListener.m_listener</code>)?</p>