Android: How can I add HTML links inside a ListView?

后端 未结 5 683
旧时难觅i
旧时难觅i 2020-12-04 23:19

How would I go about adding clickable links inside a ListView?

5条回答
  •  再見小時候
    2020-12-04 23:27

    Hmm, it seems that adding textcontent.setMovementMethod(LinkMovementMethod.getInstance()); makes it so that the clicks on the textview's text parts are no longer passed through to the listview below.

    I found a simple workaround under Issue 3414, Comment 27:

    An easy way to work around this problem is to call "setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);" on the listView views as they are added. You'll be able to select rows, click on rows and click on child checkboxes and buttons.

    It worked perfectly for me, although some casting was required:

    View v;
    ((ViewGroup)v).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    

提交回复
热议问题