prevent从一个小部件得到多次点击在短短 [英] Prevent a widget from getting clicked multiple times in a short span
问题描述
我有一个按钮,点击后,节省了画布图像文件,然后调用另一个活动。我遇到的问题是,经过测试,我发现,用户可以连续点击按钮两次活动调用之前,导致被写入两个文件。
I have a button that when clicked, saves a canvas to an image file and then calls another activity. The problem I am having is that through testing, I've noticed the user can click the button twice in a row before the activity is called, resulting in two files being written.
我还与另一个活动纺纱注意到了同样的问题。我在连续连续点击他们两次,最多弹出包含我所有的微调项目2列表视图。
I also noticed the same problem with spinners in another activity. I click them twice in a row in succession and up pops up 2 list views containing all my spinner items.
我一直在试图谷歌这一点没有多少运气。有没有一个简单的解决这个?
I've been trying to Google this without much luck. Is there a simple fix to this?
感谢。
推荐答案
那么事实证明,我不得不实施两项建议得到这个工作。 +1对你们每一个人。
Well as it turns out, I had to implement both suggestions to get this to work. +1 to each of you.
我用了一个不确定的进度对话框,和一个布尔值,像这样:
I used an indeterminate progress dialog, and a boolean value like so:
Button send = (Button) findViewById(R.id.send);
send.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mAllowSave) {
mAllowSave = false;
showDialog(SAVING_DIALOG);
mSaveFileThread = new SaveFileThread(handler);
mSaveFileThread.start();
}
}
});
这篇关于prevent从一个小部件得到多次点击在短短的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!