Reputation: 53
I have custom ListView item with ImageView and TextView. TextView contains HTML string with urls and some regular text. Im my adapter I have code similar to
tv.setText(Html.fromHtml("<a href='http://google.com'>google</a>"));
tv.setMovementMethod(LinkMovementMethod.getInstance());
and this works great but onListItemClick
isn't executed when I click on item outside url, whole item looks like inactive.
When I click on url I want to fire default action form urls and when I click on regular text or on ImageView I want to execute onListItemClick
is it possible?
Second question, is it possible to start activity using <a href="...">start some activity</a>
?
Upvotes: 2
Views: 2533
Reputation: 993
You can't make an intent form an anchor.
It's ok and recommended that you use onListItemClick
(it saves you a lot of work), and if you want to open the link in the browser (without using a webview
) you can use this an intent, this is an example:
Intent myIntent = new Intent(Intent.ACTION_VIEW,ContentURI.create("http://www.google.com"));
startActivity(myIntent);
Hope this helps.
Upvotes: 1
Reputation: 542
You need to specify a callback for each of the views that you wish to select. I believe you have three different items: The Listview
object, which contains a TextView
and an ImageView
.
If you would like to have different behavior for each different piece, you need to create a callback for each different piece. You can set a callback in the XML declaration of the view by setting
android:onClick="myCallback"
http://developer.android.com/reference/android/view/View.html#attr_android:onClick
Upvotes: 0