what’s the difference between registerForContextMenu :
Registers a context menu to be shown for the given view (multiple views can show the context menu). This method will set the View.OnCreateContextMenuListener on the view to this activity
Call registerForContextMenu() and pass it the View you want to give a context menu. When this View then receives a long-press, it displays a context menu.
and setOnCreateContextMenuListener :
Register a callback to be invoked when the context menu for this view is being built. If this view is not long clickable, it becomes long clickable.
which one to use? and about the long clickable stuff : both are doing the same thing…
Thanks
When in doubt… look at the Android source code! It is open source, after all. 🙂
git://android.git.kernel.org/platform/frameworks/base.git/core/java/android/view/View.java:
git://android.git.kernel.org/platform/frameworks/base.git/core/java/android/app/Activity.java:
So, the answer is that they’re the same.
registerForContextMenu()does nothing except invokesetOnCreateContextMenuListener().