Skip to content

onLinkClick never called #25

Open
Open

Description

@indywidualny

I tried to implement OnLinkClickListener to handle clicks of HTML links. Unfortunately it doesn't work. Links are highlighted correctly but onLinkClick(String url) is never called after clicking a link.

My layout hierarchy:

<ScrollView
    <LinearLayout
        <TextView />
        <View />
        <TextView />
        <View />
        <uk.co.deanwild.flowtextview.FlowTextView>
            <ImageView />
        </uk.co.deanwild.flowtextview.FlowTextView>
    </LinearLayout>
</ScrollView>

Some code:

public class RssFragment extends Fragment implements OnLinkClickListener {


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

        // ...

        Spanned html = Html.fromHtml(rss.getSummary() + rss.getDescription(),
                new RssImageGetter(getActivity()), null);
        flowTextView.setText(html);
        flowTextView.setOnLinkClickListener(this);
    }


    @Override
    public void onLinkClick(String url) {
        Log.e("Click", url);
    }

Has anyone any idea what's wrong?

Activity

  1. congxc commented on Nov 3, 2016

    @congxc

    please add fun:
    public boolean onTouchEvent(MotinEvent event){
    mClickHandler.onTouch(this,event);
    return super.onTouchEvent(event);
    } in FlowTextView.java;
    and change fun
    public boolean onTouch(View view,MotionEvent event){
    ...
    if(distance < 10){
    if(event_code == MotionEvent.ACTION_DOWN){
    ...
    }
    }
    ...
    } in ClickHandler.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions