It's a usability problem
I've used LinkMovementMethod.getInstance()
to allow the textview scroll and the URLS clickable (to open the browser), the problem is that's creates a confusion, when the user RELEASE the scroll on a link it automatically opens the Google Chrome browser, instead of do nothing. Every scroll open's the browser (because there is a lot of links).
So, before open the browser I want to display a Dialog asking for "Do you want open the link?", I tried a lot, but I can't identify any listeners
Other solution would be only open the browser only if the CLICK and the RELEASE were performed in the same link (in this case is more guaranteed that the user did not make any scroll)
I'm also open to other suggestions
A lot of links as you can see
The XML is briefly:
<etc.TextViewCustomizado
android:layout_width="match_parent"
app:nomeFonte="Cairo_Regular"
android:textSize="17sp"
android:id="@+id/textview"
android:textColor="@android:color/black"
android:textColorLink="@color/azul2escuro"
android:layout_height="match_parent" />
So, as you can see, it's just a textview that contains all information, passed by:
textview.setText(Html.fromHtml(
getResources().getString(R.string.lic1)
));
textview.setMovementMethod(LinkMovementMethod.getInstance());
The resource R.string.lic
:
<![CDATA[
Programming libraries (Linguagens de programação)
<br>
<a href="https://github.com/rengwuxian/MaterialEditText">MaterialEditText</a>
by
<a href="https://github.com/rengwuxian">rengwuxian</a>
licensed under
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>
..continues
Thanks
I found an alternative, using WebView
XML:
<LinearLayout
...>
<WebView
android:id="@+id/wv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Activity:
private WebView wv = (WebView) findViewById(R.id.wv);
wv.loadData(getResources().getString(R.string.lic1), "text/html; charset=utf-8",null);