Android菜单详解(四)——应用高低文菜单ContextMenu(国外英语资料)
Android菜单详解(四)——使用上下文菜单ContextMenu
The Android menu is detailed (4) -- using the context menu ContextMenu
Before the Android menu, (2) - create and respond to the options menu "and" Android menu, (3) - SubMenu and IconMenu explained in detail in the options menu, SubMenu and icon menu. Today we're going to talk about another Menu that is widely used -- the Context Menu, Context Menu.
ContextMenu profile
In Windows, we have become accustomed to right-click on the file to execute the "open", "rename", "shear", "delete" operation, such as the right-click popup menu is the context menu. You might laugh, "haha, you don't even have shortcuts." It is. Well, this... Let me give you an example. Sure, the shortcuts in Windows can help us to improve our efficiency, but this isn't working in android. Note: android's context menu items can't be keyboard shortcuts. Because mobile operating mode and the use of the mouse PC operating in a different way, the android is through long according to a view element to pop up the context menu (PS: now most smartphones is full of touch screen, no physical keyboard, no need to use shortcuts, the innovation can be attributed to jobs in 07 revolutionary iPhone, retired old Joe and salute to him!) It is. In addition, even ICONS and submenus can't be used in the context menu item for Android. So, how does the context menu for Android work? See below
As shown in figure, the context Menu inherits the android.view.menu, so we can add Menu items to the context Menu as we did with the Options Menu. The biggest difference between the context Menu and the Options Menu is that the owner of the Options Menu is the Activity, and the owner of the context Menu is the View in the Activity. Each Activity has one and only one Options Menu, which serves the entire Activity. And an Activity tends to have multiple views, not every View has a context menu, which requires that we specify it by registerForContextMenu (View View).
Although the context menu of the ow