title: How to display a Dialog inside a View?
body: <p>I´m new to android-programming and for the first program I was trying to do a simple Pong-Clone.
  My program is stitched together from different how-to's and the little bit I was able to handle myself.</p>
  <p>The baseline:
  When I press the &quot;play&quot; button it calls my &quot;GameActivity&quot; which sets my &quot;GameView&quot; as its ContentView. Inside the GameView I handle everything from the game, the ball bouncing, the player(s) and the enemy. But my problem is how to get out of it once one player wins.</p>
  <p>At first I wanted to simply call a dialog which asks the player if he wants to play again or go back to the menu, but I cant do anything Activity related of course, because I'm in the &quot;GameView&quot;. If I try to it always tells me I can't because &quot;non-static methods cannot be referenced from a static context&quot;.</p>
  <p>So my GameActivity is quite simple:</p>
  <pre><code>
  
  public class GameActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(new GameView(this));
  
  
      }
  }
  </code></pre>
  <p>At first I simply to put something like this into my View:</p>
  <pre><code>        InfoDialog infoDialog = new InfoDialog();
          infoDialog.show(getSupportFragmentManager(), &quot;infoDialog&quot;);
  </code></pre>
  <p>But as I said as far as I understood I can't do that in a View.</p>
  <p>TLDR: How can I stop or change the ContentView from my Activity or call a dialog inside that View?</p>
  <p>Like I said I'm very new to Android-programming so sorry if the way that I did this is very convoluted.</p>