ContextMenu继承自Menu,不过二者都是interface,都是只声明不干事的,有源码为证:
难道是等到其他类implement ContextMenu的method?这些类又是什么呢?另外,在使用中直接用的是ContextMenu类的对象啊……如:
public onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo info){……}哪位高手来解释?
难道是等到其他类implement ContextMenu的method?这些类又是什么呢?另外,在使用中直接用的是ContextMenu类的对象啊……如:
public onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo info){……}哪位高手来解释?
解决方案 »
- 急!!求帮看一下android XML的问题T.T
- 求助大侠!!反复使用cursor后报错,我如何关闭cursor而在下一次启用cursor时又不受影响呢
- 请问Android模拟器中的浏览器设置中的Website setting为什么总是灰色不可用?
- popupWindow获取焦点后,parent如何响应点击事件
- 有没有对NDK开发比较熟悉的啊?
- 求一个开源SNS系统
- bootStrap 如何 修改 nvabar 适应性 min-width
- 多界面调用统一导航菜单栏问题……求大神帮忙
- java.lang.NoSuchMethodError: android.support.v7.widget.RecyclerView.findViewHold
- Android开发中点击一张图片出现另一张图片,并且出现的图片停留在原图片的前面
- 人为控制activity的生命周期问题
- 菜鸟问个基础问题 100分,进者有分
public void registerForContextMenu(View view) {
view.setOnCreateContextMenuListener(this);
}
这部分代码在Activity.java类中,它去调用View.java中的以下方法:
public void setOnCreateContextMenuListener(OnCreateContextMenuListener l) {
if (!isLongClickable()) {
setLongClickable(true);
}
mOnCreateContextMenuListener = l;
}
OnCreateContextMenuListener的实现如下,也在View.java中,
public interface OnCreateContextMenuListener {
void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo);
}
整个过程如此,onCreateContextMenu(ContextMenu menu,View v,ContextMenuInfo info)只是回调函数而已
而ContextMenu继承Menu,Menu最终由MenuBuilder类来实现,具体看MenuBuilder.java
不错。现在知道了,是ContextMenuBuilder实现的!