• 我们适配器中也相应的把 textview 给删除


    package nd.no.xww.bottomnavigationlayout;

    import android.content.Context;
    import android.support.annotation.NonNull;
    import android.support.v7.widget.RecyclerView;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ImageView;
    import android.widget.TextView;

    import com.bumptech.glide.Glide;

    import java.util.List;
    import java.util.Map;

    /**
    * @author xww
    * @desciption :
    * @date 2019/7/24
    * @time 12:06
    */
    public class RecyclerGridAdapter extends RecyclerView.Adapter<RecyclerGridAdapter.ViewHolder> {

    Context context;
    List<Map<String, Object>> data;

    public RecyclerGridAdapter(Context context, List<Map<String, Object>> data) {
    this.data = data;
    this.context = context;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.recycler_one_view_2_item, viewGroup, false);
    return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int i) {
    Glide.with(context).load(data.get(i).get("pic")).into(holder.img);
    holder.name.setText(data.get(i).get("name").toString());
    }

    @Override
    public int getItemCount() {
    return data.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

    ImageView img;
    TextView name;

    public ViewHolder(@NonNull View itemView) {
    super(itemView);

    img = itemView.findViewById(R.id.img_recy_item_2_pic);
    name = itemView.findViewById(R.id.tv_recy_item_2_name);

    }
    }
    }
    然后,是数据做一下简单的修改,把对应的 desc 数据给删除:

    private void addGridData() {
    Map<String, Object> map = null;
    Random random = new Random();
    for (int i = 0; i < 30; i++) {
    int n = random.nextInt(pics.length);
    map = new HashMap<>();
    map.put("pic", pics[n]);
    map.put("name", names[n]);
    gridData.add(map);
    }
    }
    ---------------------

  • 相关阅读:
    .htaccess中的apache rewrite规则写法详解(未完)
    Linux LVM逻辑卷配置过程详解(创建、扩展、缩减、删除、卸载、快照创建)(未完)
    Linux的单用户模式
    linux proc目录和常用操作
    struts2 中的 addActionError 、addFieldError、addActionMessage的方法
    OGNL和类型转换
    ognl概念和原理详解
    java垃圾回收器
    java堆和栈的区别
    js的call()通俗解释
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11347010.html
Copyright © 2020-2023  润新知