Android动态添加TextView

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/sanyang730/article/details/51395951

LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);

   for (int i = 0; i < items.size(); i++)
 {      
    TextView mTv= new TextView(mContext);       
    mTv.setLayoutParams(params);
    mTv.setLineSpacing(1.2f, 1.2f);//设置行间距
    mTv.setTextColor(mContext.getResources().getColor(R.color.text_light_black));
    mTv.setTextSize(TypedValue.COMPLEX_UNIT_SP,15); 
    mTv.setText(i+1+"."+items.get(i).getSubName());         
    System.out.println("mTv="+mTv.getText()+items.get(i).getSubName());
    holder.ll_content.addView(mTv,i,params);

 }
展开阅读全文

没有更多推荐了,返回首页