title: How to access setOnClickListener of a button in custom view in android?
body: <p>I am very new to Android Development and this is my first Android App.</p>
  <p>Here is how my MainActivity layout looks like:</p>
  <p><a href="https://i.stack.imgur.com/OEZlC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OEZlC.png" alt="enter image description here" /></a></p>
  <p>And this is the Component Tree of the MainActivity</p>
  <p><a href="https://i.stack.imgur.com/QdVGB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QdVGB.png" alt="enter image description here" /></a></p>
  <p>The gridView is a custom view and I have a <code>resetGrid</code> function in it which looks something like this</p>
  <pre><code>public class GridView extends View {
  
      resetGird(){
          // stuff that resets grid;
      }
  }
  </code></pre>
  <p>Here is the problem I am facing:</p>
  <p>I can access the <code>setOnClickListener</code> of the reset button in the <code>MainActivity</code> file but not in the <code>GridView</code> file where the <code>resetGrid</code> function is located.</p>
  <pre><code>        resetButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Toast.makeText(PathFind.this, &quot;reset&quot;, Toast.LENGTH_SHORT).show();
              }
          });
  </code></pre>
  <p>I want to access this <code>setOnClickListener</code> of the reset button in the <code>GridView</code> file also and call the <code>resetGrid</code> function whenever the button is pressed.</p>
  <p>Not only that, my plan is to use all the controls listed in the image (start button, diagonal checkbox, speed slider) to control the GridView. But I can't seem to find a way to do that.
  All the controls are available in the main_activity but I can't use them in the GridView.</p>