在我的片段(OnCreateView
)中调用适配器到我的recView。
recView = (RecyclerView)root.findViewById(R.id.recView);
adapter = new CustomListAdapter(PokemonValues.pokemonList);
recView.setAdapter(adapter);
适配器接收值,但不打印。
public class CustomListAdapter extends RecyclerView.Adapter<CustomListAdapter.pokemonViewHolder> {
private ArrayList<Pokemon> datos;
public static class pokemonViewHolder extends RecyclerView.ViewHolder {
private TextView tvMaxCp;
private TextView tvPokemon;
public pokemonViewHolder(View itemView) {
super(itemView);
tvMaxCp = (TextView)itemView.findViewById(R.id.tvMaxCP);
tvPokemon = (TextView)itemView.findViewById(R.id.tvPokemon);
}
public void bindTitular(Pokemon t) {
tvPokemon.setText(t.getCandyEvolve());
tvMaxCp.setText(t.getMaxCP());
}
}
public CustomListAdapter(ArrayList<Pokemon> datos) {
this.datos = datos;
}
@Override
public pokemonViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View itemView = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.listview_custom, viewGroup, false);
pokemonViewHolder tvh = new pokemonViewHolder(itemView);
return tvh;
}
@Override
public void onBindViewHolder(pokemonViewHolder viewHolder, int pos) {
Pokemon item = datos.get(pos);
viewHolder.bindTitular(item);
}
@Override
public int getItemCount() {
return datos.size();
}
我正在进行调整但没有进入pokemonViewHolder
课程。我忘记了一些方法?
我有另外一个像这样的适配器并且工作正常。
由于