由于我上次发布了一个与问题不相关的代码而导致我的问题被破解,所以我将使用正确的代码再试一次...
所以这就是问题所在,我一直在为Android的GoogleMaps API运行一些测试,当我尝试在我的地图上使用CustomItemizedOverlay来使用我的图像时,我注意到当我使用getDrawable访问我的图像时,它返回null,即使当我使用ctrl + backspace选择要访问的drawable时,eclipse本身显示我的图像存在 :/
因为这个问题,我已经头痛了几个小时。有什么线索错在哪里吗?
提前感谢:)
PS:打印显示当我使用ctrl + backspace时,eclipse在资源中显示我的图像http://img.photobucket.com/albums/v328/thiagoshaman/errordrawable.png
代码:
import java.util.List;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
public class MapHandlerActivity extends MapActivity {
private MapView mapView;
private static final int latitudeE6 = 37985339;
private static final int longitudeE6 = 23716735;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
setContentView(R.layout.maphandler);
mapView = (MapView) findViewById(R.id.map_view);
mapView.setBuiltInZoomControls(true);
List<Overlay> mapOverlays = mapView.getOverlays();
Resources res = this.getResources();
Drawable drawable = res.getDrawable(R.drawable.android_tiny_image);
CustomItemizedOverlay itemizedOverlay = new CustomItemizedOverlay(drawable, this);
GeoPoint point = new GeoPoint(latitudeE6, longitudeE6);
OverlayItem overlayItem = new OverlayItem(point, "Olá", "Estou em Athena, Grécia!");
itemizedOverlay.addOverlay(overlayItem);
mapOverlays.add(itemizedOverlay);
MapController mapController = mapView.getController();
mapController.animateTo(point);
mapController.setZoom(6);
}
@Override
protected boolean isRouteDisplayed() {
return true;
}
}