Amt*_*t87 60
使用
android:autoLink="phone"
Run Code Online (Sandbox Code Playgroud)
在xml布局文件中的textView中
zie*_*ikk 27
Android有一个明确用于此目的的实用程序:Linkify
TextView noteView = (TextView) findViewById(R.id.noteview);
noteView.setText(someContent);
Linkify.addLinks(noteView, Linkify.ALL);
Run Code Online (Sandbox Code Playgroud)
另请参阅:https://android-developers.googleblog.com/2008/03/linkify-your-text.html
Kei*_*ino 20
import android.text.util.Linkify;
Linkify.addLinks(text, Linkify.PHONE_NUMBERS);
Run Code Online (Sandbox Code Playgroud)
你可以像这样在 TextView 中使用它,
设置android:autoLink="phone"如下,
<TextView
android:layout_width="fill_parent"
android:id="@+id/text"
android:layout_height="wrap_content"
android:autoLink="phone"
android:gravity="center"
android:linksClickable="true"
android:text="@string/txtCredits" />
Run Code Online (Sandbox Code Playgroud)
然而,
由于某种原因,上面的代码并不总是有效。因此,还添加以下代码,
TextView textView = (TextView) findViewById(R.id.text);
textView.setMovementMethod(LinkMovementMethod.getInstance());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20932 次 |
| 最近记录: |