Clicking on "A" and dragging on the square "B", that would work in TextView AB .... here is my implementation but it doesn't work :(

public class MainActivity extends Activity implements View.OnTouchListener { Button btn, btn2; TextView txw; String dates; int slide = 100; float x; float y; @SuppressLint("ClickableViewAccessibility") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn = (Button) findViewById(R.id.btn); btn2 = (Button) findViewById(R.id.btn2); txw = (TextView) findViewById(R.id.txw); btn.setOnTouchListener(this); btn2.setOnTouchListener(this); txw.setOnTouchListener(this); } @SuppressLint("SetTextI18n") @Override public boolean onTouch(View view, MotionEvent motionEvent) { x = motionEvent.getX(); y = motionEvent.getY(); float ex = btn2.getX(); float ey = btn2.getY(); switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: // Π½Π°ΠΆΠ°Ρ‚ΠΈΠ΅ dates = (String) btn.getText(); Log.e(TAG, "onTouch: DAtes = =" + dates ); break; case MotionEvent.ACTION_MOVE: // Π΄Π²ΠΈΠΆΠ΅Π½ΠΈΠ΅ if (x >= ex && x <= ex && y >= ey && y <= ey ){ dates = dates+btn2.getText(); } break; case MotionEvent.ACTION_UP: // отпусканиС break; case MotionEvent.ACTION_CANCEL: break; } txw.setText(dates); return true; } 

OnTouch ()

  • x> = ex & & x <= ex will return true only if x = ex. Similarly with the second part. You need to fix the conditions. What did you want to write there? - Andriy Martsinkevych
  • Corrected now can help? - Nurkan
  • @AndriyMartsinkevych Please help - Nurkan
  • @talex help - Nurkan
  • You still have the old condition in question. If it is not possible to fix it on your own then email me at martsinkevych@gmail.com - Andriy Martsinkevych

0