Why it is recommended to use staticfor classextended from RecyclerView.ViewHolderif I create a new instance of this class in a method onCreateViewHolder, and I think this instance is used for each element:
@Override
public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recyclerview,parent,false);
return new RecyclerViewAdapter.RecyclerViewHolder(view);
}
@Override
public void onBindViewHolder(RecyclerViewHolder holder, int position) {
String textTop = noticias.get(position).getHora()+ noticias.get(position).getTemperatura();
holder.textViewTop.setText(textTop);
holder.textViewBot.setText(noticias.get(position).getTexto());
}
public static class RecyclerViewHolder extends RecyclerView.ViewHolder{
public TextView textViewTop;
public TextView textViewBot;
public RecyclerViewHolder(View view){
super(view);
textViewTop = (TextView) view.findViewById(R.id.textView4);
textViewBot = (TextView) view.findViewById(R.id.textView5);
}
}
source
share