0

me he encontrado con el siguiente error jugando un poco a ver si consigo guardar una fotografía tomada o seleccionada de la galería, en una base de datos, y que aparezca en un RecyclerView cuando añado un elemento.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.vidamrr.basededatosejemplo, PID: 24393
android.content.res.Resources$NotFoundException: Drawable com.vidamrr.basededatosejemplo:id/ivperfil with resource ID #0x7f080060
Caused by: android.content.res.Resources$NotFoundException: Resource "com.vidamrr.basededatosejemplo:id/ivperfil" (7f080060) is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=5 r=0x7f080060}
    at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:789)
    at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:659)
    at android.content.res.Resources.getDrawableForDensity(Resources.java:891)
    at android.content.res.Resources.getDrawable(Resources.java:833)
    at android.content.Context.getDrawable(Context.java:605)
    at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:463)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:203)
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
    at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
    at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:86)
    at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:94)
    at com.vidamrr.basededatosejemplo.AdaptadorCustom.onBindViewHolder(AdaptadorCustom.kt:45)
    at com.vidamrr.basededatosejemplo.AdaptadorCustom.onBindViewHolder(AdaptadorCustom.kt:12)
    at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
    at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)
    at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752)
    at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
    at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
    at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
    at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
    at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
    at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
    at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
    at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4194)
    at android.view.View.layout(View.java:20822)
    at android.view.ViewGroup.layout(ViewGroup.java:6401)
    at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1183)
    at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:870)
    at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:889)
    at android.view.View.layout(View.java:20822)
    at android.view.ViewGroup.layout(ViewGroup.java:6401)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:20822)
    at android.view.ViewGroup.layout(ViewGroup.java:6401)
    at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:444)
    at android.view.View.layout(View.java:20822)
    at android.view.ViewGroup.layout(ViewGroup.java:6401)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout(View.java:20822)
    at android.view.ViewGroup.layout(ViewGroup.java:6401)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)

E/AndroidRuntime:     at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
    at android.view.View.layout(View.java:20822)
    at android.view.ViewGroup.layout(ViewGroup.java:6401)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at com.android.internal.policy.DecorView.onLayout(DecorView.java:944)
    at android.view.View.layout(View.java:20822)
    at android.view.ViewGroup.layout(ViewGroup.java:6401)
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2948)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2635)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1779)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7810)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
    at android.view.Choreographer.doCallbacks(Choreographer.java:723)
    at android.view.Choreographer.doFrame(Choreographer.java:658)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6938)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Por lo que he podido mirar el error podría estar en las siguientes lineas: -AdaptadorCustom.kt:45

holder.perfil?.setImageResource(item?.perfil!!)

-AdaptadorCustom.kt:12

class AdaptadorCustom(items: ArrayList<Sondeo>, var listener:ClickListener, var longClickListener: LongClickListener): RecyclerView.Adapter<AdaptadorCustom.ViewHolder>()

La verdad es que llevo un buen rato intentando ver cual podría ser el problema y no consigo dar con el.... ¿alguna idea?

Muchas gracias

1 respuesta 1

0

El problema es el indicado en el LogCat,

android.content.res.Resources$NotFoundException: Drawable com.vidamrr.basededatosejemplo:id/ivperfil with resource ID 0x7f080060 Caused by: android.content.res.Resources$NotFoundException: Resource "com.vidamrr.basededatosejemplo:id/ivperfil" (7f080060) is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=5 r=0x7f080060}

aunque indica que el recurso no existe, en realidad la "imagen" que tratas de asignar al ImageView holder.perfil no es una imagen.

holder.perfil?.setImageResource(...)

es muy importante asignar un recurso que sea una imagen, por ejemplo:

holder.perfil?.setImageResource(R.drawable.ic_launcher)

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.