title: Clicking a button 3 times in a row to trigger a toast?
body: <p>I was just wondering how to create a toast (or trigger something else to happen) when clicking on button 3 times in a row?</p>
  
  <p>For example: I've created a coin flip so far and I want a toast to appear if the user manages to get 3 heads/tails in a row.</p>
  
  <p><strong>This is my current code:</strong></p>
  
  <pre><code>        if (randomNumber == 1) {
  
          Log.i("Result", "Heads");
  
          greycoin.animate().alpha(0).setDuration(1000).rotationYBy(1800);
          redcoin.animate().alpha(1).setDuration(1000).rotationYBy(1800);
  
          view.animate()
                  .withEndAction(new Runnable() {
                      @Override
                      public void run() {
                          Toast.makeText(MainActivity.this, "Heads", Toast.LENGTH_SHORT).show();
                      }
                  })
                  .start();
  
      } else {
  
          Log.i("Result", "Tails");
  
          greycoin.animate().alpha(1).setDuration(1000).rotationYBy(1800);
          redcoin.animate().alpha(0).setDuration(1000).rotationYBy(1800);
  
          view.animate()
                  .withEndAction(new Runnable() {
                      @Override
                      public void run() {
                          Toast.makeText(MainActivity.this, "Tails", Toast.LENGTH_SHORT).show();
                      }
                  })
                  .start();
  
      }
  
  }
  </code></pre>
  
  <p>I'm still incredibly new to Java and programming, so please pardon my poor programming vocabulary. </p>
  
  <p>Thank you very much in advance!</p>