Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int simpleValue = 200;
- findViewById(R.id.up).setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v) {
- if (simpleValue <=20 && simpleValue > 0)
- {
- simpleValue = simpleValue - 2;
- }
- else
- {
- simpleValue = simpleValue - 20;
- }
- mEditor.putInt("value", simpleValue).apply();
- double dely = 1/(simpleValue*0.001*2);
- String formattedDouble = String.format("%.2f", dely);
- Toast.makeText(MainActivity.this, "Переменная= " + formattedDouble, Toast.LENGTH_SHORT).show();
- }
- });
- findViewById(R.id.up).setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- switch(event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- if (simpleValue <=20 && simpleValue > 0)
- {
- simpleValue = simpleValue - 2;
- }
- else
- {
- simpleValue = simpleValue - 20;
- }
- break;
- }
- mEditor.putInt("value", simpleValue).apply();
- double dely = 1/(simpleValue*0.001*2);
- String formattedDouble = String.format("%.2f", dely);
- Toast.makeText(MainActivity.this, "Переменная= " + formattedDouble, Toast.LENGTH_SHORT).show();
- return false;
- }
- });
Add Comment
Please, Sign In to add comment