title: ListView: How to go to a new activity on clicking a button in the ListView?
body: <p>I have a ListView on MainActivity and each item contains a textView and a button.</p>
  
  <p>I want to go to an Activity(say X) on clicking the button in the list.
  So my first thought was to setOnClickListener for the button in my custom adapter and use intent to go to activity X.
  I wrote this inside <code>setOnClickListener</code> of button in the custom adapter:</p>
  
  <p><code>Intent intent = new Intent(MainAcivity.this, ActivityX.class);</code></p>
  
  <p>I can not pass <code>MainActivity.this</code> as the first parameter for the intent as it is not the enclosing class.</p>
  
  <p>What can I do?</p>
  
  <p>My goal is to go from <code>MainActivity</code> to <code>ActivityX</code> on clicking the button inside of a <code>ListView</code>.</p>