Вопрос

What I want to do is make a phone number click-able I guess you can say.

On my app there is two phone numbers on two different tabs. I want the user to be able to press the phone number (either or) and it will call the number from their phone.

Can you please lead me in the right direction! Thank you!

Это было полезно?

Решение 2

I found the answer on this website

Android – Creating links using linkify | aviyehuda.com

TextView myPhone = (TextView) findViewById(R.id.textView2);
myPhone .setText("the number you want");
Linkify.addLinks(myPhone , Linkify.PHONE_NUMBERS);

Другие советы

Here's some code that will do this for you:

    tvPhone = (TextView) findViewById(R.id.tvPhone);
    tvPhone.setOnClickListener(new OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            Intent callIntent = new Intent(Intent.ACTION_DIAL);
            callIntent.setData(Uri.parse("tel:+" + tvPhone.getText().toString().trim()));
            startActivity(callIntent );
        }
    });
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top