Q: How to achieve on first click listener in android? I have a customView , i want to set onClick which will only be called on the very first click. In which i want to start a thread which will start a counter on other TextView , with simple onClickListener with each click a new threads starts which is a problem . How can i achieve such task ?

A: Another option is in your onClick() method do set a null listener, i.e.
@Override
public void onClick(View view) {
    // disable any other clicks from now on
    customView.setOnClickListener(null);
    ...
}


A: I think this is only logic problem, So I solve this problem by using a boolean variable for the first click:
    boolean isFristClick = true;
    @Override
    public void onClick(View v) {
        if (isFristClick) {
            // Start your counter Thread here
            isFristClick = false;
        } else {
            // Do nothing
        }

    }


A: What about making a workaround for that?!! like assigning a boolean value to tell if it's the first click:
private boolean first_click = true;

your_view.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        if(first_click){
             first_click = false;
             // Do something on first click
        }else{
             // Do another thing on later clicks
        }

    }
});

