对于这样的事情,我通常使用带有Runnable 的处理程序,以便在 X用户未执行特定操作后执行操作。milliseconds首先,创建一个runnable和一个handlerfinal android.os.Handler handler = new android.os.Handler();private Runnable runnable;private final long DELAY = 3000; // how many milliseconds you want to wait然后添加onClickListener:myButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { }});然后,在onClick事件内部,删除callbacks并重新实例化,handler如下所示:if(runnable != null) { // in this case the user already clicked once at least handler.removeCallbacks(runnable);}runnable = new Runnable() { @Override public void run() { //this code will run when user isn't clicking for the time you set before. }};handler.postDelayed(runnable, DELAY);最后结果:final android.os.Handler handler = new android.os.Handler();private Runnable runnable;private final long DELAY = 3000; // how many milliseconds you want to wait@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // all your previous stuffs myButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(runnable != null) { // in this case the user already clicked once at least handler.removeCallbacks(runnable); } runnable = new Runnable() { @Override public void run() { //this code will run when user isn't clicking for the time you set before. } }; handler.postDelayed(runnable, DELAY); } });}我希望这会有所帮助,如有任何问题,请随时提出