0

To display a one page story in my app, I am using a recylerview with each viewholder containing a text paragraph or an image.

@Override
public void bindItem(Story story, Asset asset) {
        super.bindItem(articleBodyBlock, asset);
        TextView textView = (TextView) itemView.findViewById(R.id.text);
        textView.setLinksClickable(true);
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        textView.setText(story.text, TextView.BufferType.SPANNABLE);
}

On marshmallow devices only, I am able to select text. But when I scroll down to another paragraph (or scroll back up to the same paragraph) and try a long press, I don't get the marshmallow floating text selection bar.

Sagar Hatekar
  • 8,700
  • 14
  • 56
  • 72
  • This is because your view has been unbind and the next time you scroll back the view is normally just bound, but not the selection. You should keep track for which items (indexes) you had selection and restore it once again the same item (index) is rebound. – Nikola Despotoski Mar 21 '16 at 21:39
  • Thank you. But what about when I scroll down to a completely new textview - why is that no longer selectable? – Sagar Hatekar Mar 21 '16 at 21:47
  • Make sure your TextView on older version is setTextIsSelectable to true. Maybe because previous action mode is not finished. Try adding a callback and keep `ActionMode`, once a textview that started the action mode is detached, just check if not null and call finish to action mode. – Nikola Despotoski Mar 21 '16 at 21:57
  • Gotcha - yes, i am setting setTextIsSelectable to true in onBind of my viewholder. Thanks for the suggestion of callback. I added both callback and callback2 - where do you suggest I call actionMode.finish() ? Inside onDestroy of the callback? – Sagar Hatekar Mar 21 '16 at 22:11
  • If it is active and holder gets unbound finish it there. – Nikola Despotoski Mar 21 '16 at 22:12
  • can u show a snippet on how to do it? – Sagar Hatekar Mar 22 '16 at 15:48

0 Answers0