2016-11-21 86 views
1

我正在使用下面的代碼在點擊TextView時打開撥號。問題是它不適用於三星平板電腦10英寸的設備。它打開一個對話框,其中包含「保存聯繫人」和「關閉」選項,而不是打開撥號。我測試過在聯想7英寸(使用api level 19)和Motorolla droid turbo(使用api level 22)上使用相同的代碼,但它工作正常,但三星10英寸平板電腦(使用api level 21)顯示與上述選項的對話。我錯過了什麼,或者這是API特定的行爲?以下是代碼。TextView的自動鏈接屬性在Android中不起作用?

 <TextView 
      android:layout_marginLeft="10dp" 
      android:textColor="@color/white_color" 
      android:layout_marginTop="10dp" 
      android:id="@+id/tv_phone" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:autoLink="phone" 
      android:textColorLink="@color/white_color" 
      android:layout_below="@+id/tv_address" 
      android:text="PH: (800) 579-4875 (310) 534-1505" /> 
+0

的問題很可能是三星的固件,它通常是一大堆不同的其他Android設備,並在共同使用的情況下 –

+0

是的,可能是一種奇特的方式行事。我正在考慮同樣的事情,但不知道這個愛人。 –

+0

@AbdulWaheed您的三星平板電腦10英寸它有呼叫功能? –

回答

0

您可以設置點擊事件處理程序來開始撥號。它必須適用於不同的固件。

textView.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     Intent intent = new Intent(Intent.ACTION_DIAL); 

     intent.setData(Uri.parse("tel:" + "phone number here")); 
     startActivity(intent); 
    } 
}); 
0

試試這個

TextView phone = (TextView) layout.findViewById(R.id.idPhone); 
phone.setAutoLinkMask(Linkify.PHONE_NUMBERS);