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