Android - how to turn numbers in a TextView into buttons

88 views Asked by At

My utility app requires the user to select a meeting from the calendar, then it removes the non-numerical text, and parses what remains using some logic, with the final aim of identifying two numbers only.

Whenever the app fails to remain with 2 numbers only, I want to open a new activity in which the user will "tell" the app which 2 numbers are the relevant ones. So I want to display the meeting title, location, and description in 3 TextViews but all numbers should be clickable with a special onClick action that will trigger some methods that handle the identified two numbers... My question is about how to turn the numbers in the textViews to be clickable and have the special onClick action. I don't think I can use Linkify as I cannot put an onClickListener on the links. My only idea now is to turn the numbers into clickable buttons and add the relevant listener to the buttons. 1) Any suggestion on how to do this conversion other than simple step by step parsing? 2) Any better idea than using buttons?

Thanks a million

1

There are 1 answers

1
Tuxxy_Thang On

call setOnClickListener(this) on the TextView and supply a onClick method in your code