How does one properly set an onclicklistener within another class?
<p>I have an activity which does all the setup process, i.e. creating the initial view and the OnClickListener, which then at some point creates an object passing the activity and OnClickListener as parameters. The object then does it's own setup, changing to view and setting TableRows with the OnClickListener. I run into the issue that when ever I click on one of the Rows, it seems OnClick(View v) is not called. The code seems solid but I'm either missing something or my implementation simply wont work. Any help would be appreciated.</p>

<pre><code>public class MyActivity extends Activity {
   private Object mObject;
   private TextView textView;

    private OnClickListener mListener = new OnClickListener() {
        public void onClick(View v) {
           switch(v.getId()) {
           case R.someId:
              mObject = new Object(MyActivity.this, mListener);
              break;
           case R.id.table_row:
              doSomething();
              break;
           }
       }
    }

    textView = (TextView)findViewById(R.id.someId);
    textView.setOnClickListener(mListener);
}

public class Object {
    private Activity mActivity;
    private OnClickListener mListener;
    private TableRow tableRow;
    public Object(Activity a, OnClickListener o) {
       mActivity = a;
       mListener = o;
       mActivity.setContentView(R.layout.layout);
       tableRow = (TableRow)findViewById(R.id.table_row);
       tableRow.setOnClickListener(mListener)
    }
}
</code></pre>

<p>Edited code as suggested:</p>

<pre><code>public class MyActivity extends Activity implements OnClickListener{
   private Object mObject;
   private TextView textView;

    @override
    public void onClick(View v) {
        switch(v.getId()) {
        case R.someId:
           mObject = new Object(MyActivity.this, mListener);
           break;
        case R.id.table_row:
           doSomething();
           break;
        }
    }
}
</code></pre>

<p>I omitted the Object class because with the above code onClick is not called without setting the OnClickListener with view.setOnClickListener(this); This also does not allow me to pass the Listener itself as a parameter, as far as I know.</p>
