I have this code working for my method that calls an EditText, I tried to use the same code for a TextView but it does not work. The text does not turn into a hyperlink like it does in EditText, does anybody know why?
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.link_view);
// make sure that setText call comes BEFORE Linkify.addLinks call
tv.setText(tv.getText().toString());
Linkify.addLinks(tv, Linkify.WEB_URLS);
}}
Here is the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow>
<TextView
android:id="@+id/link_lbl"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingRight="10dip"
android:text="Link" />
<TextView
android:id="@+id/link_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="google.com" />
</TableRow>
</TableLayout>
This will work fine in EditText, i just need help doing the same thing in TextView