【发布时间】:2019-04-09 11:25:12
【问题描述】:
我想让用户在允许按下 imageButton 之前等待一小段时间,我不知道最好的方法。
private class HandleClick implements View.OnClickListener {
public void onClick(View arg0) {
if(arg0.getId()==R.id.imageButton){
((TextView) findViewById(R.id.textView2)).setText("Pressed: " + ++howManyClicks1);
/* Uri uri = Uri.parse("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=1");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);*/
simpleWebView.loadUrl("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=1");
//startActivity(intent);
}
else if (arg0.getId()==R.id.imageButton1){
((TextView) findViewById(R.id.textView3)).setText("Pressed: " + ++howManyClicks2);
/*Uri uri = Uri.parse("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=2");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
//startActivity(intent);*/
simpleWebView.loadUrl("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=2");
}
else if (arg0.getId()==R.id.imageButton2){
((TextView) findViewById(R.id.textView5)).setText("Pressed: " + ++howManyClicks3);
/*Uri uri = Uri.parse("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=3");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
//startActivity(intent);*/
simpleWebView.loadUrl("https://abr.se/happyeno/?get=happyeno_svar_put&svar_id=3");
}
}
}
我不希望用户能够垃圾邮件点击 imageButtons。也许最好的方法是在按下按钮后添加延迟或禁用按钮一小段时间?
【问题讨论】:
-
单击按钮后等待 5 秒,然后执行您所需的任务 - 这是您想要的权利
-
@MurugananthamS 是的,这可能是处理它的最佳方式。
-
好的,我会参考倒计时
标签: java android imagebutton