views:

59

answers:

2

So, basically I have a custom View that contains a ListView with a custom Adapter that has the ability to read in information from the network (dumbed down HTML) and display it on a row by row basis.

All of this works, but I need the text that is read in to be parsed as HTML which contains links that can be tapped on and launched in browser.

I managed to do this by:

text.setText(Html.fromHtml(textBuffer), TextView.BufferType.SPANNABLE);
text.setMovementMethod(LinkMovementMethod.getInstance());

Works great, any <a href=""></a> links in the text are displayed as links and can be tapped.

This is a side effect of now making it so the rest of the rows in the ListView cannot be tapped (or tapped and held). Basically, all the rows are non-selectable now.

Is there any way to achieve both of what I need?

thanks!

A: 

Try setting text.setFocusable(false). By removing focus from the EditText, events will be passed onto the ListView or other items.

Sameer Segal
Still no dice. If I have a long block of text in the textBuffer with a few HTML links, the links are still clickable, but if I push (and hold) anywhere on the text without the link, it still doesn't "select (turn yellow)".Basically, I need to keep the default behavior of being able to long-press the row (for my context menu), but if there are links in there, to launch them in the browser.Thanks for the response, though.
A: 

When you put an item that is focusable inside a ListView, it automatically makes the ListView not focusable. This is the behavior you are seeing.

To make them both focusable, I believe you can adjust the descendantFocusability property of the ListView.

See this question for a similar problem.

Mayra