I collect Activity programmatically, without using the markup .xml Among other things, there are several TextView, like this:

final TextView tvDesc = new TextView(this); tvDesc.setText("Описание тут! http://тут_какой-то_адрес.com/about.php а дальше ещё какой-то текст и ещё какие-то ссылки"); tvDesc.setTextSize(14); tvDesc.setVisibility(View.VISIBLE); 

The problem is that I do not know which text will fall there, but I know that there may be links to web pages. And these links must be made active (clickable). In the xml markup, everything is simple:

 <TextView android:id="@+id/tvDescription" android:layout_width="match_parent" android:layout_height="wrap_content" android:autoLink="web" android:linksClickable="true" android:textColorLink="@color/colorPrimaryDark" android:text="@+id/tvDescription"/> 

In the android:autoLink="web" android:linksClickable="true" everything is decided, but how to achieve this in the JAVA file? Thank.

    1 answer 1

    Excuse for troubling! While I was formulating the question, I figured it out myself :) I did this:

      final TextView tvDesc = new TextView(this); tvDesc.setText("Описание тут! http://тут_какой-то_адрес.com/about.php а дальше ещё какой-то текст и ещё какие-то ссылки"); tvDesc.setTextSize(14); tvDesc.setVisibility(View.VISIBLE); tvDesc.setAutoLinkMask(webViewStyle); 

    Thanks to all.