简体   繁体   中英

Link Text with phone's dialer (Android)

So I have this TextView field and it has a number in it

<TextView android:phoneNumber="true" android:textSize="14sp" android:textColor="#283486" android:layout_width="300dip" android:id="@+id/Contact" android:gravity="bottom" android:layout_height="wrap_content" android:text="@string/phoneNumber"></TextView>

I want it so that when they touch this number it takes them to the number dialer on their phone so that they can call that number.

How would I go about that

Try to add the android:autoLink attribute:

    <TextView android:autoLink="phone"   
     android:phoneNumber="true"  
     android:textSize="14sp"   
     android:textColor="#283486"   
     android:layout_width="300dp"  
     android:id="@+id/Contact"   
     android:gravity="bottom"   
     android:layout_height="wrap_content"   
     android:text="@string/phoneNumber">  
   </TextView>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM