您的位置:首页 > 其它

多击

2016-06-02 19:17 253 查看
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];@Overrideprotected 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("被双击拉~");}}}
通过更改素质来更改次数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: