saket / Better-Link-Movement-Method

Attempts to improve how clickable links are detected, highlighted and handled in TextView
Apache License 2.0
780 stars 78 forks source link

Popup Menu doesn't work properly in Adapter #13

Closed sunnat629 closed 6 years ago

sunnat629 commented 6 years ago

OS: Naugate and Oreo

I am working on a project where I need to use TextView in Listview with verious String types like URL, Phone Number, Email etc. I have implement your lib and it works in activities but in the listview, I am facing some problem.
Assume, I have a dynamic listview with String content. At first, the popup menu doesn't show from the linkify. If I scroll up/down, it works again. Need to add that in Lolipop, it works like a charm.

Is there any solution regarding this.

Here is the sample of my XML and Java Code -

 <TextView
        android:id="@+id/body"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:autoLink="all"
        android:focusable="true"
        android:linksClickable="false"
        android:longClickable="true"
        android:textColorHighlight="@color/gray"
        android:textColorLink="@color/white"
        android:textSize="@dimen/font_size_small"
        tools:text="@tools:sample/full_names" />

-- in list adaper -

public View getView(int position, View view, ViewGroup parent) { ... BetterLinkMovementMethod.linkify(Linkify.ALL, mViewGroup).setOnLinkClickListener(urlClickListener); }

private BetterLinkMovementMethod.OnLinkClickListener urlClickListener = new BetterLinkMovementMethod.OnLinkClickListener() { @Override public boolean onClick(TextView textView, String url) { if (isPhoneNumber(url)) { PhoneLinkPopupMenu phonePopupMenu = new PhoneLinkPopupMenu(activity, textView, url.replace("tel:", "")); phonePopupMenu.show(); } return true; } };

saket commented 6 years ago

I'm sorry, but the Popup menu is not a part of the library. It's something I quickly wrote for showcasing BetterLinkMovementMethod in a sample project. I do not expect people to use it in actual projects because it's not properly tested and I do not intend to provide support for it. :)

sunnat629 commented 6 years ago

Thanks for your response. :)