Je reçois un message d'erreur disant “impossible de convertir de int à Drawable”. Je suis en train d'affecter une image des lieux. Est-il un moyen de contourner cela?

Je n'arrive pas à référencer mon image dans le dossier drawable. J'ai l'image il y a cependant, je reçois un message d'erreur indiquant que je ne peut pas convertir un int en Drawable. mon R.java fichier généré a la chaîne pour l'image, cependant, il est défini comme "public static final int restaurant=0x7f020001;"

package com.CS3040.Places;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import com.CS3040.*;
import com.CS3040.Coursework.R;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.OverlayItem;

public class PlaceOverlayItem extends OverlayItem {
    private final GeoPoint point;
    private final Place place;
    private final Drawable marker;

    public PlaceOverlayItem(Place p, String type) {
        super(p.getGeoPoint(), p.getName(), p.getFormatted_address());


        if(type.equals("restaurant")){ this.marker = R.drawable.restaurant;  }

        //super.setMarker(this.marker);
        this.point = p.getGeoPoint();
        this.place = p;
    }

    /**
     * @return the point
     */
    public GeoPoint getPoint() {
        return point;
    }

    /**
     * @return the place
     */
    public Place getPlace() {
        return place;
    }
}

OriginalL'auteur user1270217 | 2012-03-14