美文网首页
RecycleView

RecycleView

作者: 旺旺碎冰冰s | 来源:发表于2019-05-24 15:53 被阅读0次

    第一步:

    
    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);
    
            }
    
    }
    
    }
    
    

    相关文章

      网友评论

          本文标题:RecycleView

          本文链接:https://www.haomeiwen.com/subject/xrxnzqtx.html