sorry for asking this newbie question, as i am new to android development. what code should be entered in the main.java?
<resources>
<string name="strname">Clickable Text<a href="http://domain.com">Visit Website</a></string>
</resources>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:autoLink="web"
android:text="@string/strname"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
you can use Linkfy:
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText("http://www.google.com");
Linkify.addLinks(textView, Linkify.WEB_URLS);
From the documentation
Linkify take a piece of text and a regular expression and turns all of the regex matches in the text into clickable links
On textview click event write this:
Uri uri = Uri.parse("http://domain.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
that open the your URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With