Now I want to explain clearly, now in an Activity
I have a long string for example a string which have 50 words.
When I click on a word I want to get that word only.
For ex : If I click on Apple, that word should get or should print in Log
.
text1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Layout layout = ((TextView) v).getLayout();
int x = (int) event.getX();
int y = (int) event.getY();
if (layout != null) {
int line = layout.getLineForVertical(y);
int offset = layout.getOffsetForHorizontal(line, x);
Log.v("index", "" + offset + " Line :" + line);
}
return true;
}
});
I tried it and I can get offset points only but don't know how to get a whole word.
Thanks in Advance