Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使android textview自动链接其作为电话号码的值_Android_Clickable_Phone Call - Fatal编程技术网

如何使android textview自动链接其作为电话号码的值

如何使android textview自动链接其作为电话号码的值,android,clickable,phone-call,Android,Clickable,Phone Call,因此,我目前制作了一个工作应用程序,当用户输入员工姓名并进行搜索时,它会搜索我的sql数据库,并返回一个列表中的姓名、电话号码、id和地址,这样每个结果都会与下一个结果分开。我正在尝试将电话号码自动链接为电话号码,以便用户可以单击它,它将呼叫它,但我不确定如何做到这一点。是的,我已经在这个网站上阅读了其他的教程,但还没有成功。希望你们能帮我。首先,是的,我已经将权限添加到清单中 下面是我希望使textview可单击的xml布局 <TextView android:layout_wi

因此,我目前制作了一个工作应用程序,当用户输入员工姓名并进行搜索时,它会搜索我的sql数据库,并返回一个列表中的姓名、电话号码、id和地址,这样每个结果都会与下一个结果分开。我正在尝试将电话号码自动链接为电话号码,以便用户可以单击它,它将呼叫它,但我不确定如何做到这一点。是的,我已经在这个网站上阅读了其他的教程,但还没有成功。希望你们能帮我。首先,是的,我已经将权限添加到清单中

下面是我希望使textview可单击的xml布局

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="Phone Number"
    android:id="@+id/textType"
    android:layout_marginLeft="5dp"
    android:layout_below="@id/textSize"
    android:textColor="#666"
    android:clickable="true" />

在xml中的文本视图上添加:

 android:inputType="phone"
尝试添加android:autoLink=phone属性,因此您的代码应该如下所示:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="123 456 7890"
    android:id="@+id/textType"
    android:layout_marginLeft="5dp"
    android:layout_below="@id/textSize"
    android:autoLink="phone"
    android:textColor="#666"
    android:clickable="true"
/>

当我去测试它时,它只是告诉我我点击了一个我放在那里的对象,但它没有使用模拟器启动调用。列表的相对布局是否需要设置为android:clickable=true?我现在将其设置为false,因为我认为这意味着用户不能单击所有内容,只能单击设置为true的内容?对不起,我把你弄糊涂了。在我的编码体验开始一周左右是的,设置为真,试着将文本视图改为编辑文本是的,哈哈,太棒了,伙计!我很高兴这有帮助。快乐编码!
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="123 456 7890"
    android:id="@+id/textType"
    android:layout_marginLeft="5dp"
    android:layout_below="@id/textSize"
    android:autoLink="phone"
    android:textColor="#666"
    android:clickable="true"
/>