Yes, I think you see the HTC menu there.
The graphical editing context menu that you see is, I think, new to the later Desire models (Desire HD and Desire Z). What I see (with your code) in my original Desire is a pop-up text menu with a HeaderTitle heading set to "Edit Text" and a list, such as "Select All", "Copy", "Paste", etc. ., But I also see the entry "Test menu".
It occurs to me that when calling onCreateContextMenu () for things like ListView and ImageView, the menu object passed to this call is not populated by default by default. However, in the case of EditText, it is designed to interact with Clipboard, and therefore the system provides a pre-populated menu based on the state of the contents of the EditText (for example, if the text is selected, specify the Copy option; if the text in the clipboard contains the Paste option, etc. d.).
I managed to get the context menu without the "edit" parameters, clearing the title and contents, changing the code ...
@Override public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { Log.v(TAG, "Creating context menu for view="+view);
The fact that you get a graphical menu (possibly obtained from ContextMenu) suggests that the above method will not work, so the only way to create it would be to create an instance of your own ContextMenu object, rather than using the one that was passed to onCreateContextMenu ().
I completely debugged / logged everything around my code, but still I didn’t even call Activity.onCreateContextMenu ()
This seems very strange - obviously, it is called for me, since I was able to play with ContextMenu, which is passed to it.
EDIT 1: Rethinking this, you say that you click "EditText" - is that what you are actually doing (short touch down and then finger up)?
To get my ContextMenu, I have to use a "long" click (press and hold for 1 second). When I just touch my EditText, a soft keyboard appears or, if the keyboard is already visible, the cursor simply moves to another place in the EditText field.
Obviously, Desire Z has a physical keyboard, and this can lead to slightly different behavior (as well as desire Z, which has a different version of the Sense interface for my desire).
The fact that onCreateContextMenu () is never called for you can mean only one thing, and exactly what you see is NOT ContextMenu and represents some type of pop-up user interface. At the very least, this is the only logical way to understand this.
Can you confirm that the “long” press still does not create ContextMenu for you or do you continue the long press?
If you tried a long press, try changing the code as follows:
Implement OnClickListener
public class MyActivity extends Activity implements OnLongClickListener {
Set the listener for editText in onCreate ...
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); editText=(EditText )findViewById(R.id.editText); this.registerForContextMenu(editText); editText.setOnLongClickListener(this);
Add listener code ...
@Override public boolean onLongClick(View arg0) { android.util.Log.v(TAG, "onLongClick() called"); if (arg0 == editText) { android.util.Log.v(TAG, "arg0 == editText"); Toast.makeText(this, "onLongClick intercepted", 2000).show(); return true; } else { android.util.Log.v(TAG, "arg0 != editText"); return false; } }
That way, I can intercept the long print and returning "true" from onLongClick (), I tell the system that I "absorbed" the event and it does not go through to cause the creation of my ContextMenu.
If this does not work for you, and a short press still causes a popup to appear, try implementing OnClickListener and override onClick ().
The object of the exercise is that if you can intercept everything that causes the pop-up to be created that you see, you can manually create and display your own ContextMenu.