3

I have an EditText where I wanted to make link (email, web, phone) clickable. I was able to do it by using

mBodyText.setMovementMethod(LinkMovementMethod.getInstance());

it works perfectly and all links open when clicking on them. Here comes my requirement. I want to open contextual action bar (like default copy/ paste one) when user click on a link in edit text.

I know how to start a contextual action bar. But I don't know how can I catch the event when user clicks the link and to identify what kind of link it is (phone or web etc...) to show the proper menus in CAB.

After searching for hours, I come here to get the suggestion.

Prashant
  • 263
  • 1
  • 4
  • 12
  • Is there a particular reason you are doing this in an edittext, and not a textview or webview? (You should only use a exit text if you intend the user to edit information. In which case they can copy and paste it themselves since they entered it.) – Matthew Cordaro Jun 17 '14 at 20:28
  • Yes, user can edit the text at any point of time. Please read my question again. I want to handle the click event in edit text (it would be the same even if I use TextView, I guess) – Prashant Jun 17 '14 at 20:34
  • 1
    I see. Check out this solution here for a textview: http://stackoverflow.com/a/16644228/1071884. In theory it should be able to be applied to an edit text because it is a text view. – Matthew Cordaro Jun 17 '14 at 20:45
  • nope, I can not modify the link to have my package name plus I want to let user open in their preferred target application. It's just i want to display CAB rather than Contextual Action Menu. – Prashant Jun 17 '14 at 21:44
  • I think I get what you're asking. You are looking to replace the Menu and place the program selections in the Bar. (e.g.: user clicks on 'http://' and options for chrome, firefox, and opera are given in the bar.) Am I correct? – Matthew Cordaro Jun 18 '14 at 17:58
  • yes, and if it's a phone number and phone icon – Prashant Jun 19 '14 at 18:01

0 Answers0