,因爲我已經打掉我對於這件事的最後一個問題是由於發佈關於我要去用正確的密碼再次嘗試這個問題從一個不同的代碼......getDrawable返回null
所以這裏的處理,我一直在使用Android的GoogleMaps API進行一些測試,當我嘗試在我的地圖上使用我的一張圖像設置CustomItemizedOverlay時,我注意到當我使用getDrawable訪問我的圖像時,它返回null即使日食本身顯示我我的形象是在那裏,當我使用CTRL +退格時,選擇哪個可繪製我希望進入:/
因爲這個我一直在我的頭穿過牆。這裏有什麼問題的任何線索?
感謝提前:)
PS:可見日食打印顯示的資源裏面我的形象時,我用ctrl + Backspace鍵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;
}
}
你使用你的形象的延伸比png格式,JPG格式,或.gif等?它可能無法識別其他擴展類型。 [http://developer.android.com/guide/topics/resources/drawable-resource.html](http://developer.android.com/guide/topics/resources/drawable-resource.html) –
Nope :(它的一個PNG:/ – thiagocfb