基本信息
源码名称:RecyclerView 绑定图文列表例子(入门级示例)
源码大小:19.21M
文件格式:.rar
开发语言:Java
更新时间:2020-04-25
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 1 元 
   源码介绍

package haue.edu.cn.shopping;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    private RecyclerView rvGoods;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rvGoods = findViewById(R.id.rv_goods);
        rvGoods.setLayoutManager(new LinearLayoutManager(this));
        // 默认分割线
        //rvGoods.addItemDecoration(new DividerItemDecoration(this,DividerItemDecoration.VERTICAL));
        //自己设置分割线
        DividerItemDecoration decoration=new DividerItemDecoration(this,DividerItemDecoration.VERTICAL);
        decoration.setDrawable(ContextCompat.getDrawable(this,R.drawable.divider));
       // decoration.setDrawable(getResources().getDrawable(R.drawable.divider));
        rvGoods.addItemDecoration(decoration);
        MyAdapter adapter=new MyAdapter();
        rvGoods.setAdapter(adapter);
    }
}