Guest User

Untitled

a guest
Feb 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. private int simpleValue = 200;
  2. findViewById(R.id.up).setOnClickListener(new View.OnClickListener()
  3. {
  4. @Override
  5. public void onClick(View v) {
  6. if (simpleValue <=20 && simpleValue > 0)
  7. {
  8. simpleValue = simpleValue - 2;
  9. }
  10. else
  11. {
  12. simpleValue = simpleValue - 20;
  13. }
  14. mEditor.putInt("value", simpleValue).apply();
  15. double dely = 1/(simpleValue*0.001*2);
  16. String formattedDouble = String.format("%.2f", dely);
  17. Toast.makeText(MainActivity.this, "Переменная= " + formattedDouble, Toast.LENGTH_SHORT).show();
  18. }
  19. });
  20.  
  21. findViewById(R.id.up).setOnTouchListener(new View.OnTouchListener() {
  22. @Override
  23. public boolean onTouch(View v, MotionEvent event) {
  24. switch(event.getAction()) {
  25. case MotionEvent.ACTION_DOWN:
  26. if (simpleValue <=20 && simpleValue > 0)
  27. {
  28. simpleValue = simpleValue - 2;
  29. }
  30. else
  31. {
  32. simpleValue = simpleValue - 20;
  33. }
  34. break;
  35. }
  36. mEditor.putInt("value", simpleValue).apply();
  37. double dely = 1/(simpleValue*0.001*2);
  38. String formattedDouble = String.format("%.2f", dely);
  39. Toast.makeText(MainActivity.this, "Переменная= " + formattedDouble, Toast.LENGTH_SHORT).show();
  40. return false;
  41. }
  42. });
Add Comment
Please, Sign In to add comment