0
votes

In the new Android RecyclerView has someone a way to access and modify the single views based on the position ?

@Override
public void onBindViewHolder(RecycleHourAdapter.ViewHolder viewHolder, int position) {

    viewHolder.txtStunde.setText(input[position]);
}

onBindViewHolder I can access the ViewHolder and position, but not the View populated by the ViewHolder.

And onCreateViewHolder I can access the view but I do not have the position of this view.

// Create new views (invoked by the layout manager)
@Override
public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                               int viewType) {
    // create a new view
    View v = LayoutInflater.from(parent.getContext())
                           .inflate(R.layout.my_text_view, null);
    // set the view's size, margins, paddings and layout parameters
    ...
    ViewHolder vh = new ViewHolder(v);
    return vh;
}

Any idea ?

1

1 Answers

1
votes

You can always get the View from the ViewHolder using:

View view = viewHolder.itemView;