2010-07-29 72 views
0

我有幾個覆蓋繪製在一個MapView與ItemizedOverlay,並在我第一次啓動我的應用程序時工作的onTap。但是,如果我按下Android上的後退按鈕,然後再次啓動我的應用程序,onTap根本不起作用。其他觸摸感應操作正常工作,如長按地圖和幾個臉部按鈕。如果我按手機上的主頁按鈕,然後返回到我的應用程序,那麼它也是好的,所以它只在後退按鈕上。如果我第一次打開地圖應用程序等其他應用程序,然後返回到我的應用程序中,它就像復位一樣工作。在Android後退按鈕之後覆蓋onTap無法工作?

重寫onBackPressed方法將任務移動到後臺也不起作用,有沒有人有任何想法會導致這種情況?它發生在模擬器和真實設備上。

我不知道這是否會幫助,但這裏是培訓相關代碼:

public OverlayManager(MapsTest launcher) 
{ 
    m_mapView = (MapView)m_activity.findViewById(R.id.mapview); 

    // init the list to the mapview list and clear it out 
    m_overlayList = m_mapView.getOverlays(); 
    m_overlayList.clear(); 

    // create an overlay list for each overlay type 
    for(OverlayTypes o : OverlayTypes.values()) 
    { 
    m_itemOverlay[o.ordinal()] = new OverlayList(m_context.getResources().getDrawable(OverlayData.getInstance().getDrawableID(o))); 
    } 

    // init the SMS sender 
    m_smsSender = new SMSSender(); 

    m_mapMenu = new MapMenu(launcher, this); 
    m_overlayList.add(m_mapMenu); 
    m_mapView.invalidate(); 
} 


public class OverlayList extends ItemizedOverlay<MapOverlayItem> 
{ 
private ArrayList<MapOverlayItem> m_items = new ArrayList<MapOverlayItem>(); 

private int m_lastSelectedItem = 0; 

public OverlayList(Drawable d) 
{ 
    super(d); 
} 

    @Override 
    protected boolean onTap(int index) 
    { 
    if(!ProgramState.getInstance().recentStateChange()) 
    { 
     m_lastSelectedItem = index; 
     OverlayData.getInstance().setLastSelectedType(m_items.get(index).getMarkerType()); 

     InfoBalloon.show(m_items.get(index)); 
    } 

    return true; 
    } 
} 

回答

0

看來,這個問題實際上我對和Ontap方法只是不顯示正在繪製的靜態佈局因爲它是靜態的(InfoBalloon)。我不知道爲什麼,這是進入繪畫方法和一切,但是當我使它不是靜態的,它工作正常!