我想在显示上下文菜单之前做一些动作......
两个都可以用吗??
我试过:
name.setOnLongClickListener(new View.OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
//some code here before show the context menu
registerForContextMenu(name);
return true;
}
});
但是没有用
谢谢
编辑:这就是我所拥有的
for (final File dir : dirs)
{
TableRow row = new TableRow(this);
final Button name = new Button(this);
name.setOnLongClickListener(new View.OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
//DIR is a global variable. It saves clicked path
DIR = dir.getAbsolutePath()+"/";
//registerForContextMenu(name);
return true;
}
});
row.addView(name);
fileView.addView(row);
}
如您所见,我想在保存单击项目的路径后显示上下文菜单