ribot / easy-adapter

[DEPRECATED] Easy Adapters library for Android
http://ribot.github.io
Apache License 2.0
421 stars 50 forks source link

Error "The ItemViewHolder class passed into the EasyAdapter is not valid, make sure it extends ItemViewHolder." #7

Closed devloe closed 10 years ago

devloe commented 10 years ago

What's wrong with my code?

I get the following error:

'05-21 12:20:26.893: E/AndroidRuntime(3300): uk.co.ribot.easyadapter.InvalidViewHolderException: The ItemViewHolder class passed into the EasyAdapter is not valid, make sure it extends ItemViewHolder.'

And my code look like this:

EasyAdapter adapter = new EasyAdapter<Debate>(getActivity(), DebateViewHolder.class, itemList);
        list.setAdapter(adapter);

@LayoutId(R.layout.item_debate)
    public class DebateViewHolder extends ItemViewHolder<Debate> {

        @ViewId(R.id.title)
        TextView title;

        @ViewId(R.id.username)
        TextView username;

        @ViewId(R.id.date_human)
        TextView date_human;

        @ViewId(R.id.comments_count)
        TextView comments_count;

        public DebateViewHolder(View view) {
            super(view);
        }

        @Override
        public void onSetValues(Debate item, PositionInfo positionInfo) {
            title.setText(item.title);
            username.setText(item.username);
        }
    }
ivacf commented 10 years ago

Hi,

It looks like you forgot to add the data type. It should be extends ItemViewHolder<Debate>.

Also if DebateViewHolder is an inner class, then it has to be static. Otherwise the EasyAdapter won't be able to instantiate it.

devloe commented 10 years ago

Solved it.

I had to move the class to a file, loke DebateViewHolder.java.

Thanks!

devloe commented 10 years ago

Ok got it. Thanks.

ivacf commented 10 years ago

No problem!

gobinda99 commented 9 years ago

On setting proguard shows error

ivacf commented 9 years ago

@gobinda99 you have to tell proguard to keep all the classes that extend ItemViewHolder

gobinda99 commented 9 years ago

Thanks for your reply I have fixed it ...

On 25 November 2014 at 04:08, Ivan Carballo notifications@github.com wrote:

@gobinda99 https://github.com/gobinda99 you have to tell proguard to keep all the classes that extend ItemViewHolder

— Reply to this email directly or view it on GitHub https://github.com/ribot/easy-adapter/issues/7#issuecomment-64278315.