【发布时间】:2018-08-30 16:50:55
【问题描述】:
我付出了所有的努力仍然无法解决它,但我遇到了一个奇怪的问题。
问题是:
我有一个直接从Twitter 加载数据的文本视图。 Tweets 可能包含许多链接,它会显示在 textview 中,但在单击链接时,它们会在 android default browser 中打开。我想要做的是当用户点击任何链接how will I detect which link has been clicked 和open my webview instead of default browser。
这是我到目前为止所达到的:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello www.google.com Thank You"
android:autoLink="web"
android:id="@+id/activity_main_textview"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Java
TextView textView = (TextView) findViewById(R.id.activity_main_textview);
textView.setText("www.google.com is first link, www.facebook.com is second link, www.instagram.com is third link");
textView.setMovementMethod(LinkMovementMethod.getInstance());
【问题讨论】:
标签: java android android-fragments android-activity webview