0

我编写了一个应用程序,当我单击选项菜单时,它应该在视图中显示一个上下文菜单。我在 onCreate() 方法中注册了一个视图。

@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    mLatestIntent = getIntent();
    setContentView(R.layout.details_gallery);
    DataManager.getInstance().registerImageUpdateListener(this);
    mGallery = (HomeScreenGallery)findViewById(R.id.details_gallery);
    mGallery.setSingleTapListener(this);
    mAdapter = new
           EventDetailsAdapter(this,DataManager.getInstance().getChannel().getItems());
    mGallery.setAdapter(mAdapter);

    **registerForContextMenu(mGallery);**
    setData();
}

我在 onOptionsItemSelected() 方法中调用了 openContextMenu() 并将注册的视图发送给它

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
    case Constants.OPTION_MENU_SHARE:
        **this.openContextMenu(mGallery);**
        break;
    }
    return super.onOptionsItemSelected(item);
} 

但是当我点击选项菜单时没有任何显示,为什么?

4

0 回答 0