I declared these variables initially

private String level = "0", action = "0"; private int step = 1; 

Changing their meaning

 swipe.setOnTouchListener(new OnSwipeTouchListener(LevelActivity.this) { public void onSwipeTop() { action = "8"; level(); //вызываю метод, который "обрабатывает" действия pStatus = 0; step++; }});} 

I process values, everything works well.

  public void level() { System.out.println("***CURRENT NUMBER IS " + level + step + action + "***"); //Выводит 114 и другое, все ок switch (level + step + action) { //LEVEL 1 case "114": instructionsTV.setText(getString(R.string.swipe_up_1)); step = 2; break; case "138": instructionsTV.setText(getString(R.string.swipe_bottom1)); step = 3; break; case "152": instructionsTV.setText(getString(R.string.swipe_up_1)); step = 4; break; default: detect = 1; myQuittingDialogBox.show(); } } 

But the problem lies elsewhere. I bring the numbers to LogCat through another method

  public static void onDoubleTap() { new LevelActivity().singletap();} public void singletap() { System.out.println("***CURRENT NUMBER IS " + level + step + action + "***"); } 

The following is displayed: I / System.out: *** CURRENT NUMBER IS 010 ***
Although the values ​​of the variables are different

  • one
    give all the activation code, it is not clear where you announce when you call - TimurVI
  • This is an adequate behavior. You create an instance of the class and display the value of its fields. You have two classes, each with its own values. PS: I advise you to read the basics of java. - post_zeew
  • Thanks a lot - Twikoffin

0