String datetime1=rowItem.getDatetime();
SpannableString spannabledatetime1 = new SpannableString(datetime1);
spannabledatetime1.setSpan(
new RelativeSizeSpan(dimen.txtsize1),
0,
datetime1.length(),
0);
spannabledatetime1.setSpan(
new ForegroundColorSpan(color.green),
0,datetime1.length(),
0);
holder.txtLeftMsg.setText(rowItem.getMsg()+"\n"+spannabledatetime1);
我希望我的自定义txtsize1
中的日期时间和我的自定义颜色为绿色。和rowItem.getMsg()
一样,我从xml文件中获取它。这段代码是用适配器类编写的。
答案 0 :(得分:-1)
String datetime1=rowItem.getMsg() +"\n"+ rowItem.getDatetime();
SpannableString spannabledatetime1= new SpannableString(datetime1);
spannabledatetime1.setSpan(new RelativeSizeSpan(dimen.txtsize1), rowItem.getMsg(),datetime1.length(), 0);
spannabledatetime1.setSpan(new ForegroundColorSpan(color.green), rowItem.getMsg(), datetime1.length(), 0);
holder.txtLeftMsg.setText(spannabledatetime1);