Reputation: 1302
For some reason after I made textviews clickable and have autolink set to web it still doesn't open a browser. Do I need to use an event listener then handle it that way? Or is it something simple that I am overlooking? I'll start by posting the textview XML code :
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.11"
android:autoLink="web"
android:background="@drawable/back"
android:clickable="true"
android:gravity="center"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
Upvotes: 0
Views: 227
Reputation: 1302
I had to use an onclick event to handle the browser launching. I'm still an complete amateur at android programming so I got the information from here:
// Register an onClickListener
Intent broswerIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.cnn.com"));
broswerIntent.addCategory(Intent.CATEGORY_BROWSABLE);
broswerIntent.setComponent(new ComponentName("com.android.browser",
"com.android.browser.BrowserActivity"));
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(), 0, broswerIntent, 0);
Upvotes: 0
Reputation: 4638
Add below lines .
final TextView input = new TextView(this);
alert.setView(input);
input.setText(Html.fromHtml("www.google.com")); // you can pass your strings over there.
Linkify.addLinks(input, Linkify.ALL);
alert.setMessage("Test");
Hope this helps you.
Upvotes: 0
Reputation: 5593
This code was written about year ago but I think it should work:
TextView result_view = new TextView(this);
result_view.setText(Html.fromHtml("<a href=" + linkUrl + ">"+ linkTitle + "</a>"));
result_view.setMovementMethod(LinkMovementMethod.getInstance());
Upvotes: 1