• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android Button help

You could use a class variable to record the number of clicks. This would be incremented every time the button is clicked. Like this

Code:
class myActivity extends Activity {

  private int numberOfClicks;
  private final int MAX_CLICKS = 3;
  ...

  button.setOnClickListener(new OnClickListener() { 
    @Override
    public void onClick(View view) {
      numberOfClicks++;
      if (numberOfClicks >= MAX_CLICKS) {
        // Show your ad
        numberOfClicks = 0;
      }  
    }   
  });
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones