package com.test1.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity
extends
Activity
implements
OnClickListener
{
private Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.test);
btn.setOnClickListener(this);
}
long lastClick;
@Override
public void onClick(View v) {
//大于一秒方个通过
if (System.currentTimeMillis() - lastClick <= 1000)
{
showToast("点那么快干什么!!!");
return;
}
lastClick = System.currentTimeMillis();
showToast("是你点的我么...");
}
public void showToast(String str) {
Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
}
}
转:http://blog.csdn.net/liu_jun_y/article/details/9219265