Pregunta

He pasado por todos los tutoriales para mostrar una imagen en un teléfono Android desde una URL. Estoy tratando de vincular un objeto ImageView a la URL HTTP, pero sigo recibiendo un error de clase ImageView:

02-16 23: 32: 50.204: e/androidruntime (499): java.lang.runtimeException: no se puede iniciar la actividad componentInfo {com.dbresults/com.dbresults.contactView}: android.view.inflateException: binary xml line # # # 82: Error en inflando la clase ImageView

Código Theo en mi archivo Java:

 ....
 setContentView(R.layout.contact_view);
 ImageView imageView = (ImageView)findViewById(R.id.ImageView1); 
 imageView.setImageDrawable(createDrawableFromURL("http://savagelook.com/misc/sl_drop2.png"));
 ....
 private Drawable createDrawableFromURL(String urlString) {
    Drawable image = null;
try {
    URL url = new URL(urlString);
    InputStream is = (InputStream)url.getContent();
    image = Drawable.createFromStream(is, "src");
} catch (MalformedURLException e) {
    // handle URL exception
    image = null;
} catch (IOException e) {
    // handle InputStream exception
    image = null;
}

return image;
}

Mi archivo XML se ve así (la línea 82 es la etiqueta de apertura ImageView):

<LinearLayout android:orientation="horizontal"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:gravity="left" android:background="@drawable/white">
    <Imageview  android:id="@+id/ImageView1" 
                android:layout_height="wrap_content" 
                android:layout_width="fill_parent" /> 
     </LinearLayout>
¿Fue útil?

Solución

Es un error tipográfico. ¡Debería ser ImageView!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top