¿Cómo puedo registrar un menú contextual para una vista de desplazamiento?

I have an android loyout like this:

            android:layout_height="wrap_content" />

How can I register a context menu so that it will pop up when user long press anywhere in the scroll view?

I have tried find the scrollview and and register context menu for that:

ScrollView scrollView = findViewById(R.id.scrollview);

But that does not, I don't see any context menu pops up. The only way works is if I register my text view for context menu.

But that may cause bad experience since my text view sometimes can be short (1-2 lines/1-2 words) and sometimes it can be long (mult sentences).

¿Cuál es la mejor manera de arreglar esto?

preguntado el 01 de febrero de 12 a las 22:02

depending on what you want in the menu it may work to just get a reference to your ScrollView and set a LongClickListener on it. Then in the callback for that you could inflate and show the dialog yourself. Probably not ideal but I think it would work. -

1 Respuestas

Algunas ideas

Set the scrollview to be long clickable (might be false by default, not sure)


If that doesn't work, set your own OnLongClickListener, and from within it, manually call ScrollView's showContextMenu method.

Respondido 02 Feb 12, 03:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.