Neznajka
Neznajka

Reputation: 35

onClickListener to a specific text in TextView

Is it possible to use any existing onClickListiner to make click on specific text of TextView. if there is not then is it possible to link 2 text views, to look like 1 text view. I mean not in horizontal or not in vertical aligment, but when finishes one TextView from that point starts another.

Upvotes: 3

Views: 843

Answers (3)

Steve Prentice
Steve Prentice

Reputation: 23514

You can use a ClickableSpan. See this answer for an example.

Upvotes: 1

woodshy
woodshy

Reputation: 4111

You can try to implement your custom view based on TextView. In the dispatchTouchEvent(MotionEvent event) you can provide calculations depending on text size, paddings and so on that could tell that exactly part of view was pressed.
Anyway, in case if you'll grovide final goal of your separated clicks, advise could be more accurete.

Upvotes: 0

amukhachov
amukhachov

Reputation: 5900

Try to use TextWatcher. Just change focus from first view to other one in beforeTextChanged (CharSequence s, int start, int count, int after) method when s.length() == length of sequence you want to be in first TextView.

Upvotes: 0

Related Questions