TextColor not showing when row backgroundcolor set

Posted by RuAware on Stack Overflow See other posts from Stack Overflow or by RuAware
Published on 2012-11-11T22:26:49Z Indexed on 2012/11/11 23:00 UTC
Read the original article Hit count: 167

Filed under:
|

if my row is colored red the text wont set to green and bold italic. When debugging I can see it telling the TextView to set each textViews setting.

Thanks

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);

© Stack Overflow or respective owner

Related posts about android

Related posts about table