我正在 Android 中编写一个相当简单的应用程序,大部分代码都在处理漂亮的动画以使其看起来不错。
我的问题是有时单击一个按钮,但只有在单击另一个按钮后才调用来自 onClick 侦听器的相关 onClick() 。
它表明Android正在“缓冲”事件并分组处理它们,而不是在它们生成时处理它们。
有没有人遇到过这个问题,或者可以提出解决方案?
我不确定它是否重要,但我通常使用匿名对象作为我的听众,这对我来说更有意义。
        score.setVisibility(VISIBLE);
    score.setClickable(true);
    score.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            soundEffect.soundForId(SoundEffect.DELETE_SOUND);
            player.setToRmove(true);
                            //Toggle trash button to replace the score button and
                            // identify for the user that this player is due to be deleted
            score.setVisibility(GONE);
            score.setClickable(false);
            trashButton.setVisibility(VISIBLE);
            trashButton.setClickable(true);
            trashButton.invalidate();
        }
    });