Manabu-GT / ExpandableTextView

Android's TextView that can expand/collapse like the Google Play's app description
Apache License 2.0
4.08k stars 791 forks source link

Links are not clickable in ExpandableTextView #51

Open naveenvenkannagari opened 7 years ago

naveenvenkannagari commented 7 years ago

Setting HTML text as a part of ExpandableTextView using (Html.fromHtml(String, int)) . when there are hyperlinks as a part of HTML content its display as a link. the clicking of that link will collapse the view instead of opening that in browser. Is the textview which is wrapped in ExpandableTextView (LinearLayout) is textview.setMovementMethod(LinkMovementMethod.getInstance()); ??

masamiYaaaa commented 7 years ago

As we can

ShuichiSyad commented 6 years ago

@naveenvenkannagari The links are clickable.. To create an expendableTextView, we have to make a TextView inside it with id of "expandable_text". Just declare the "expandable_text" in your java class

TextView expandable_text = (TextView) findViewById(R.id.expandable_text);

then set the LinkMovementMethod to it

expandable_text.setMovementMethod(LinkMovementMethod.getInstance());

Make sure theres NO android:autoLink="web" on your layout because it will render your text wrong

zdunex25 commented 5 years ago

If I use more than one ExpandableTextView (as in list view) it only work for first entry, moreover we are not able to rename IDs (like expandable_text), so I cannot make unique IDs for another entries.

pmbranco commented 3 years ago

Tried this but with no success. Can someone provide a way to implement it? The expandable textview closes when I click on the link inside the expanded textview.

zdunex25 commented 3 years ago

Tried this but with no success. Can someone provide a way to implement it? The expandable textview closes when I click on the link inside the expanded textview.

I had to import ExpandableTextView class and do some corrections in both ExpandListener and CollapseListener : contentText.setText(Html.fromHtml(text)); contentText.setMovementMethod(LinkMovementMethod.getInstance()); in order to make links clickable.

Then in layout.xml i used: com.my.packagename.ExpandableTextView to load edited class instead of original one.

pmbranco commented 3 years ago

I am doing precisely that... going to recheck it and let you know. Thanks for helping me out!

pmbranco commented 3 years ago

I can do it on the textview while not expanded. But it didn´t work on the expanded text. Needed to also add to the xml element: android:linksClickable="true" android:autoLink="all"