의심 ... 안드로이드 소스 코드를 봐! 그것은 결국 오픈 소스입니다. :)
자식 : //android.git.kernel.org/platform/frameworks/base.git/core/java/android/view/View.java :
/**
* 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.
*
* @param l The callback that will run
*
*/
public void setOnCreateContextMenuListener(OnCreateContextMenuListener l) {
if (!isLongClickable()) {
setLongClickable(true);
}
mOnCreateContextMenuListener = l;
}
자식 : //android.git.kernel.org/platform/frameworks/base.git/core/java/android/app/Activity.java는 :
/**
* Registers a context menu to be shown for the given view (multiple views
* can show the context menu). This method will set the
* {@link OnCreateContextMenuListener} on the view to this activity, so
* {@link #onCreateContextMenu(ContextMenu, View, ContextMenuInfo)} will be
* called when it is time to show the context menu.
*
* @see #unregisterForContextMenu(View)
* @param view The view that should show a context menu.
*/
public void registerForContextMenu(View view) {
view.setOnCreateContextMenuListener(this);
}
그래서, 대답은 같은 것 때문이다. registerForContextMenu()
은 setOnCreateContextMenuListener()
을 호출하는 것 외에는 아무런 효과가 없습니다.
그들은 똑같은 것처럼 보입니다. –