开发者

EditText.setMovementMethod with LinkMovement Method in ListView - loses ability to "Click" on rows in the list

So, basically I have a custom View that contains a ListView with a custom Adap开发者_JAVA百科ter 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!


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜