2011-03-15 59 views
2

以下代碼可以正常打開警報對話框。我想知道是否可以從地圖疊加類中打開上下文菜單?是否有可能從Android中的地圖覆蓋項目打開上下文菜單?

@Override 
protected boolean onTap(int index) { 
    OverlayItem item = mOverlays.get(index); 
     AlertDialog.Builder dialog = new AlertDialog.Builder(mContext); 
     dialog.setTitle(item.getTitle()); 
     dialog.setMessage(item.getSnippet()); 
     dialog.show(); 

    return true; 
} 

回答

0

這可能工作。

registerForContextMenu(mapView); // in onCreate 

protected boolean onTap(int index) { 
    mTappedItem = index; 
    openContextMenu(); 
    return true; 
} 

public boolean onContextItemSelected(MenuItem item) { 
    // do something if mTappedItem is valid. 
    return true; 
} 
1

不,你不能在MapView的

打開上下文菜單

我想有我想大多數的方法,但一切都是徒勞事件的onTap打開上下文菜單。

也許你應該使用Alert.Builder和它的三個按鈕來執行操作,如果你想。或更好地具有定製的警報視圖。

registerForContextMenu(mapView); 

openContextMenu(mapView); 

不工作

相關問題