Kostya Khuta
Kostya Khuta

Reputation: 1856

How to make call to number from text in textView?

I need to make somethink like this: iphone screenshot

How can I select phone number with a blue color, and make on click listener on it? I don't want to create other textView for it. I tried:

@Override
public void onClick(View v) {
    Intent callIntent = new Intent(Intent.ACTION_CALL);
    callIntent.setData(Uri.parse("tel:+" + tv.getText().toString().trim()));
    startActivity(callIntent);

}

Upvotes: 0

Views: 2060

Answers (2)

jpm
jpm

Reputation: 3430

I haven't used it, but you can set a link mask for a textview so that it automatically creates clickable links of phone numbers (or email addresses or urls...) see http://developer.android.com/reference/android/widget/TextView.html#setAutoLinkMask(int) This probably just opens the system's default action and you can't add a clicklistener, but maybe that's what you need...?

Upvotes: 1

pshegger
pshegger

Reputation: 2606

I think this is what you're looking for.

Upvotes: 5

Related Questions