title: Getting the updated value from Surfaceview class
body: <p>I have declared an global int counter variable like this :</p>
  
  <pre><code>public class GamePanel extends SurfaceView implements SurfaceHolder.Callback{
  public int counter = 0;
  </code></pre>
  
  <p>I am updating its value onclick:</p>
  
  <pre><code>public boolean onTouchEvent(MotionEvent event) {
      int x = (int) event.getX();
      int y = (int) event.getY();
      for (Balloon aMBalloonArray : mBalloonArray) {
          if (aMBalloonArray.isCollition(x, y)) {
              aMBalloonArray.reposition();
              popSound.start();
              counter = counter + 1;
              Log.d("GamePanel", "Score:" + counter);
          }
      }
      return super.onTouchEvent(event);
  }
  </code></pre>
  
  <p>I use this method to get the value:</p>
  
  <pre><code>public int getCounter() {
      return counter;
  }
  </code></pre>
  
  <p>but it displays 0 and not the updated value. can you tell me what to do and how to display the updated variable. Thanks in advance.</p>
  
  <p>calling getcounter():</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      //set to full screen
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.final_score);
  
  
      String score = getIntent().getStringExtra("SCORE");
      finalScoreTextView = (TextView)findViewById(R.id.final_score);
      gamePanel = new GamePanel(this);
      finalScoreTextView.setText(gamePanel.getCounter());
      finalScoreTextView.invalidate();
  }
  </code></pre>