因为我已经解决了关于这个问题的最后一个问题,因为我发布了与这个问题不同的代码,所以我将用正确的代码再次尝试......
所以事情是这样的,我一直在使用适用于 Android 的 GoogleMaps API 运行一些测试,当我尝试使用我的一张图像在地图上设置 CustomItemizedOverlay 时,我注意到当我使用 getDrawable 访问我的图像时即使 Eclipse 本身向我显示了当我在选择我希望访问的可绘制对象时使用 ctrl+backspace 时我的图像就在那里,它仍然返回 null :/
为此,我几个小时以来一直在绞尽脑汁。关于这里出了什么问题的任何线索吗?
提前致谢 :)
PS:打印显示当我使用 ctrl + backspace 时 eclipse 显示资源内的图像http://img.photobucket.com/albums/v328/thiagoshaman/errordrawable.png http://img.photobucket.com/albums/v328/thiagoshaman/errordrawable.png
Code:
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;
}
}
尝试将图像放在所有可绘制质量文件夹中(drawable-hdpi/drawable-ldpi 等)
可能是您使用的模拟器或设备具有不同的密度,并且正在尝试从另一个文件夹中提取图像。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)