0

I have a bluetooth mouse connected to my phone (galaxy s2, Android 4.1). I'm trying to get the cursor position and display it in a TextView using the OnHoverListener:

private class MouseListener implements View.OnHoverListener {
 @Override
 public boolean onHover(View view, MotionEvent motionEvent) {
 String position = motionEvent.getX() + " " + motionEvent.getY();
 mousePosition.setText(position);
 return false;
 }
}

This is set on a RelativeLayout:

layout.setOnHoverListener(new MouseListener());

The problem is that it only updates when I click and not when I move the mouse.

asked Oct 16, 2015 at 19:38
2

1 Answer 1

1

The code is correct. I tried it with another mouse and it works.

answered Oct 17, 2015 at 20:45
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.