TextView selectable just on long click

早过忘川 提交于 2021-01-27 13:08:18

问题


I have many TextViews and ImageViews interleaved and I want to select one word of a TextView with a long click. If I set all the TextViews as selectable with mTextView.setTextIsSelectable(true) the scroll doesn't work well and when I click over one of them, the view scrolls to set it as first element.

I thought that I could do something like:

mTextView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                mTextView.setTextIsSelectable(true);
                return false;
            }
        });

But I have to perform the long click two times, one to set it as selectable and the second to select the word. And then I have to override something like onScroll or onClick to set the TextView as not selectable again.

Someone knows some solution?

Edit: I need to select words of the TextViews but I just want to perform the long click over that TextViews. They are created in runtime and added to a FrameLayout. Maybe I't could be possible perform all gestures on the FrameLayout minus the onLongPress...

来源:https://stackoverflow.com/questions/42598797/textview-selectable-just-on-long-click

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!