RecycleView的Adapter中方法的作用

RecyclerViewAdapter.class :继承RecyclerView.Adapter后,会重写三个方法:


public class RecycleViewAdapter extends RecyclerView.Adapter {
 
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return null;
    }
 
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
 
    }
 
    @Override
    public int getItemCount() {
        return 0;
    }
}

onCreateViewHolder()方法,负责承载每个子项的布局。它有两个参数,其中一个是 int viewType;
onBindViewHolder()方法,负责将每个子项holder绑定数据。俩参数分别是RecyclerView.ViewHolder holder, int position;

你可能感兴趣的:(Android篇)