如果我的行是红色的,则文本不会设置为绿色和粗斜体。调试时,我可以看到它告诉 TextView 设置每个 textViews 设置。
TableRow row = new TableRow(getContext());
row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
String[] items = list.get(l).split(":");
for(int i=0; i < items.length; i++){
//see if i need to colour row
if(items[i].startsWith("colorme_") == true) {
if (items[i].substring(8).equals("red") == true) {
row.setBackgroundColor(Color.RED);
}
} else {
//create a temp textview then add to row
TextView tempTV = new TextView(getContext());
tempTV.setText(items[i].toString());
//test against correct answers and colour text view green if correct
if (correctAnswers != null && correctAnswers.size() > i) {
if (correctAnswers.get(i).equals(items[i].toString()) == true) {
tempTV.setTextColor(Color.GREEN);
tempTV.setTypeface(null, Typeface.BOLD_ITALIC);
}
}
row.addView(tempTV,lpTextView);
}
}
//add the row
tempTable.addView(row);