zoukankan      html  css  js  c++  java
  • 在某个条目中动态添加多个小布局条目

    //获取数据源
    List<PromotionTagBean> promotionTag = listGoodsBean.getPromotionTag();
    int size = promotionTag.size();
    //holder.mAddLabel : 条目中的线性布局linearlayout
    //添加之前先移除
    holder.mAddLabel.removeAllViews();
    if (size > 0 && promotionTag != null) {
    for (int i = 0; i < size; i++) {
    View view = View.inflate(context, R.layout.category_acticity, null);
    //设置参数
    LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
    LinearLayout.LayoutParams.MATCH_PARENT,
    LinearLayout.LayoutParams.WRAP_CONTENT);
    param.setMargins(Utils.dip2px(context, 5), 0, 0, Utils.dip2px(context, 10));
    view.setLayoutParams(param);
    ImageView iv = (ImageView) view.findViewById(R.id.iv_prom_logo);
    TextView tv = (TextView) view.findViewById(R.id.tv_prom_desc);
    tv.setSingleLine();
    tv.setEllipsize(TextUtils.TruncateAt.END);
    setPic(iv, promotionTag.get(i).getPromotionLogo());
    tv.setText(promotionTag.get(i).getPromotionDesc());
    //循环添加各个条目子布局
    holder.mAddLabel.addView(view);
    }
    }
  • 相关阅读:
    VS2017gets的使用
    UITableViewCell自定义高度
    登录注册页面的
    监听键盘- KeyBoard
    UITableViewDelete 删除
    UITabView 添加
    navigationbar背景图 设置左右按钮
    Navigation1 PUSH & POP
    母传键老师课堂笔记 -----ViewController的生命周期
    可折叠tableView
  • 原文地址:https://www.cnblogs.com/liheng-android/p/6640363.html
Copyright © 2011-2022 走看看