android.content.res.Resources$NotFoundException: 资源 ID #0x7f07007e [英] android.content.res.Resources$NotFoundException: Resource ID #0x7f07007e

查看:25
本文介绍了android.content.res.Resources$NotFoundException: 资源 ID #0x7f07007e的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在应用中实现类似的功能,这是回收视图中 Viewholder 的片段.

I am Trying to implement like feature in the app, here is the snippet from the Viewholder in the recycled view.

回收器定制适配器

public class PostAdapterViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

TextView title,user,description,tag,time,designation;
Long date;
ImageView imageView,bookmark,profilepic,sharebutton,like;
RelativeLayout head;
LinearLayout content;
DatabaseReference reference;
Context context;
String name;

public void setContext(Context context) {
    this.context = context;
}

public PostAdapterViewHolder (final View itemView) {
    super(itemView);
    itemView.setOnClickListener(this);
    head = (RelativeLayout) itemView.findViewById(R.id.head);
    content = (LinearLayout) itemView.findViewById(R.id.content);
    imageView =(ImageView)itemView.findViewById(R.id.imageview);
    designation = (TextView) itemView.findViewById(R.id.designation);
    like =(ImageView)itemView.findViewById(R.id.like);
    profilepic = (ImageView) itemView.findViewById(R.id.imageView2);
    bookmark =(ImageView)itemView.findViewById(R.id.bookmark);
    title = (TextView) itemView.findViewById(R.id.title);
    description = (TextView) itemView.findViewById(R.id.description);
    time = (TextView) itemView.findViewById(R.id.date);
    tag = (TextView) itemView.findViewById(R.id.tag);
    sharebutton = (ImageView) itemView.findViewById(R.id.sharebutton);
    user = (TextView) itemView.findViewById(R.id.username);

    like.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            ImageView i = (ImageView) itemView.findViewById(R.id.like);
            Drawable a = i.getBackground();

            if (a.getConstantState().equals(context.getDrawable(R.drawable.emptyup).getConstantState())){

                i.setImageDrawable(context.getDrawable(R.drawable.fillup));

            } else {

                i.setImageDrawable(context.getDrawable(R.drawable.emptyup));

            }

        }
    });

  }
} 

}

01-09 10:43:45.747 6602-6602/ctize.connectplus.com.communitize E/AndroidRuntime:致命异常:主要进程:ctize.connectplus.com.communitize,PID:6602android.content.res.Resources$NotFoundException: 资源 ID #0x7f07007e在 android.content.res.Resources.getValue(Resources.java:1397)在 android.content.res.Resources.getDrawable(Resources.java:843)在 android.content.Context.getDrawable(Context.java:458)在 ctize.connectplus.com.communitize.PostAdapterViewHolder$2.onClick(PostAdapterViewHolder.java:98)在 android.view.View.performClick(View.java:5226)在 android.view.View$PerformClick.run(View.java:21350)在 android.os.Handler.handleCallback(Handler.java:739)在 android.os.Handler.dispatchMessage(Handler.java:95)在 android.os.Looper.loop(Looper.java:148)在 android.app.ActivityThread.main(ActivityThread.java:5582)在 java.lang.reflect.Method.invoke(Native Method)在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

01-09 10:43:45.747 6602-6602/ctize.connectplus.com.communitize E/AndroidRuntime: FATAL EXCEPTION: main Process: ctize.connectplus.com.communitize, PID: 6602 android.content.res.Resources$NotFoundException: Resource ID #0x7f07007e at android.content.res.Resources.getValue(Resources.java:1397) at android.content.res.Resources.getDrawable(Resources.java:843) at android.content.Context.getDrawable(Context.java:458) at ctize.connectplus.com.communitize.PostAdapterViewHolder$2.onClick(PostAdapterViewHolder.java:98) at android.view.View.performClick(View.java:5226) at android.view.View$PerformClick.run(View.java:21350) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5582) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

推荐答案

当应该显示相关活动时,您的应用程序崩溃?

Your app crash when the activity concerned should be displayed ?

检查您的活动中是否有这样的可绘制 v24

Check if in you activity you have a drawable v24 like this

然后,如果是,请将文件的显示从 Android 更改为位于文件层次结构最顶部的 Project:从

Then, if yes, change the display of your files from Android to Project at the very top of the hierarchy of your files : From

并将drawable v-24目录下的drawable拖放到drawable目录下.

And drag and drop the drawable in the directory drawable v-24 to the directory drawable.

仅此而已.试试看没问题

That's all. Try if it's ok

我发现该问题可能出现在 Android 6 API 23 上,但不会出现在更高的 API 上

Edit : I found that the problem may arise on the Android 6 API 23 but not for higher API

这篇关于android.content.res.Resources$NotFoundException: 资源 ID #0x7f07007e的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆