RecycleView

2019-05-24  本文已影响0人  旺旺碎冰冰s

第一步:


implementation'com.android.support:recyclerview-v7:26.0.0'

第二步:


private RecyclerViewrecyclerView;

recyclerView = findViewById(R.id.rv_view);

RecyclerView.LayoutManager layoutManager =new LinearLayoutManager(this);

recyclerView.setLayoutManager(layoutManager);

//设置adapter

recyclerView.setAdapter(new MyAdapter());

class MyAdapterextends RecyclerView.Adapter{

@Override

    public ViewHolderonCreateViewHolder(ViewGroup parent, int viewType) {

View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.family_item,null);

        return new ViewHolder(view);

    }

@Override

    public void onBindViewHolder(ViewHolder holder, int position) {

}

@Override

    public int getItemCount() {

return 20;

    }

public class ViewHolderextends RecyclerView.ViewHolder{

public ViewHolder(View itemView){

super(itemView);

        }

}

}

上一篇下一篇

猜你喜欢

热点阅读