2012-08-09 5 views
0

토글 나는 풍선을 보여주는이 좋은 라이브러리를 사용합니다. 문제는 현재 풍선의 오버레이 전체 상태를 전환하는 것입니다.사용자 정의 풍선 버튼

어떻게 수정합니까? 여기에 내 코드, 미리 감사드립니다!

@Override 
protected void setupView(Context context, final ViewGroup parent) { 

    // inflate our custom layout into parent 
    LayoutInflater inflater = (LayoutInflater) context 
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View v = inflater.inflate(R.layout.baloon_overlay, parent); 

    ToggleButton favorite = (ToggleButton) v 
      .findViewById(R.id.toggleButton1); 

    favorite.setOnClickListener(new OnClickListener() { 
     @Override 
     public void onClick(View arg0) { 
      if (isFav==false) { 
       isFav=true; 
       System.out.println("true");} 
      else { 
       isFav=false; 
       System.out.println("false"); 
      } 
     } 
    }); 
} 

답변

0

첫째로, "현재 풍선의 오버레이 전체 상태를 전환합니까?" 어떤 주를 말하는 겁니까?

상태를 전환하는 정의에 관계없이 다음과 같이 제안합니다. 동일한 풍선에 여러 오버레이를 추가하는 대신 각 오버레이마다 별도의 ItemizedOverlay를 사용해보십시오. 나는 현재의 풍선 대신 내 전체 오버레이가 영향을 받아 비슷한 문제를 겪었습니다. 그래서 문제가 해결되었습니다.

itemizedOverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView); 

    GeoPoint point = new GeoPoint((int)(51.5174723*1E6),(int)(-0.0899537*1E6)); 
    CustomOverlayItem overlayItem = new CustomOverlayItem(point, "Tomorrow Never Dies (1997)", 
      "(M gives Bond his mission in Daimler car)", 
      "http://ia.media-imdb.com/images/M/[email protected]@._V1._SX40_CR0,0,40,54_.jpg"); 
    itemizedOverlay.addOverlay(overlayItem); 

    //This bottom line is what I'm trying to suggest 
    itemizedOverlay2 = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView); 
    GeoPoint point2 = new GeoPoint((int)(51.515259*1E6),(int)(-0.086623*1E6)); 
    CustomOverlayItem overlayItem2 = new CustomOverlayItem(point2, "GoldenEye (1995)", 
      "(Interiors Russian defence ministry council chambers in St Petersburg)", 
      "http://ia.media-imdb.com/images/M/[email protected]@._V1._SX40_CR0,0,40,54_.jpg");  
    itemizedOverlay2.addOverlay(overlayItem2); 

    mapOverlays.add(itemizedOverlay); 
:

은 제가 mapviewballoons에서 (custommap 활동을) 코드를 사용하는 것이 좋습니다 노력하고있어 보여 드리죠