多击

来源:互联网 发布:4y4淘宝店铺装修安全吗 编辑:程序博客网 时间:2024/06/07 09:11
package com.hello.duoji;import android.os.SystemClock;import android.support.v7.app.AlertDialog;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;public class MainActivity extends AppCompatActivity {    long[] mHits = new long[2];    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);    }    public  void  treeClick(View view) {        /**         *  src the source array to copy the content.   拷贝的原数组         srcPos the starting index of the content in src.  是从源数组那个位置开始拷贝         dst the destination array to copy the data into.  拷贝的目标数组         dstPos the starting index for the copied content in dst.  是从目标数组那个位置开始去写         length the number of elements to be copied.   拷贝的长度         */        //拷贝数组操作        System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);        mHits[mHits.length - 1] = SystemClock.uptimeMillis();  // 将离开机的时间设置给数组的第二个元素,离开机时间 :毫秒值,手机休眠不算        if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {  // 判断是否多击操作            System.out.println("多击了...");            AlertDialog.Builder builder =new AlertDialog.Builder(this);            builder.setTitle("被双击拉~");        }    }}


通过更改素质来更改次数

0 0
原创粉丝点击