尝试这种方式,首先在活动类文件上声明全局变量,如下所示:
int count = 0;
之后,添加您的点击监听器,如下所示:
yourButton.setonClickListener(v -> { if (count == 0) { // the first click count++; // do your stuff }else { // the second click count = 0; // initialize the count to limit the button click just for the first and the second time only // do your stuff } });


