Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecyclerView.ViewHolder - view is every time null #20

Open
kevinvenclovas opened this issue May 4, 2022 · 0 comments
Open

RecyclerView.ViewHolder - view is every time null #20

kevinvenclovas opened this issue May 4, 2022 · 0 comments

Comments

@kevinvenclovas
Copy link

@Override
public View getView(int i, View view, ViewGroup viewGroup)

The view element ist on every call null, so every time i need to create a new view How can i use the viewholder?

@Override
public View getView(int i, View view, ViewGroup viewGroup) {

    DataViewHolder viewHolder;

    if(view == null){

        LayoutInflater layoutInflater = LayoutInflater.from(viewGroup.getContext());
        view = layoutInflater.inflate(R.layout.item_card,viewGroup,false);
        viewHolder = new DataViewHolder(view);
        view.setTag(viewHolder);

    }else{
        // DO NOT TRIGGER
        viewHolder = (DataViewHolder) view.getTag();
    }

    viewHolder.bindData(context, (ProductCardData) getItem(i));

    return view;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant