我需要在 oncreate 方法中打开上下文菜单。我做什么:
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
cont = new CustomViewContainer(this);
setContentView(cont);
this.openContextMenu(cont);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Select");
menu.add(0, v.getId(), 0, "a");
menu.add(0, v.getId(), 0, "b");
menu.add(0, v.getId(), 0, "c");
}
}
但是我没有看到菜单。请帮忙!