Question

I'm not sure if this possible, but I'd like to somehow have text on rows of a List to be selectable for copying but also, long press to bring up a contextual menu.

I know that long press is required for selecting individual text, but its being overridden by the fact that I need to apply a long press to the entire row for displaying the contextual menu.

I'm sure others have come across this problem?

Edit: Ok, I just realised text can be selected by not only Long press but also, double click/press. So that can be used in this case instead

Was it helpful?

Solution

try this:

    yourEditText.setFocusableInTouchMode(false);
    yourEditText.setSelectAllOnFocus(true);
    yourEditText.clearFocus();
    yourEditText.setOnClickListener(new View.OnClickListener(){

        public void onClick(View v){
            yourEditText.requestFocusFromTouch();
        }
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top