Really stupid question here, but could not find an answer googling.
I have a clickable textview.
How to retrieve the row’s number that is clicked??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The question isn’t that stupid because there is no built-in method, that I know of, to do this.
However you can use:
getLineHeight()to determine how tall each line is in the TextView andMotionEvent#getY()in an OnTouchListener to calculate which line was clicked.Basic example:
From the
getLineHeight()documentation:So if you have modified any attribute listed above, you’ll need to account for that as well.