如何在精确触摸屏幕 3 次后转到下一个 activity

How to go to next activity after touching the screen exact 3 times

我是 Android 的新手。有一个屏幕有 imageview 并在图像上精确触摸 3 次,下一个 activity 应该出现..

请帮我解决这个问题 谢谢大家

您必须管理相同的计数。这样做:

int touchCount = 0;

ImageView img = (ImageView) findViewById(R.id.image);
img.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
       touchCount  = touchCount  + 1;
      if (touchCount  == 3){
              touchCount=0;
              Intent intent = new Intent(mContext, ActivityA.class);
              startActivity(intent);
           }else{
               Toast.makeText(getApplicationContext(),
                "Click more"+ Integer.toString(3-touchCount) +" time to navigate next screen."),
                Toast.LENGTH_LONG).show();
       }
});
ImageView img = (ImageView) findViewById(R.id.img);
img.setOnClickListener(new View.OnClickListener() {
    private int clickCount;

    @Override
    public void onClick(View v) {
        if (++clickCount == 3) {
            Intent intent = new Intent(MainActivity.this, OtherActivity.class);
            startActivity(intent);
        }
    }
});

其中 MainActivity 是您当前 activity 的名称,OtherActivity 是您的目标。

int click = 0;

image.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
       click  = click  + 1;
      if (click == 3){
              click=0;
              Intent intent = new Intent(Activity.this, nextActivity.class);
              startActivity(intent);
           }
});