Android records a common setTextColor bug, androidbug
I accidentally made a mistake when writing code today. After careful inspection, we can only record it to prevent you from making the same mistake.
The Code is as follows:
remote.setTextColor(summaryId, R.color.news_have_read);
As shown above, the Code cannot display the color normally in any case. You have to switch to the following code:
remote.setTextColor(summaryId,0xfdfdfdfd);
There is always a lot of trouble to write color values .. In color. xml.
Finally, we can find that the write is the most correct.
remote.setTextColor(summaryId, mContext.getResources().getColor(R.color.news_is_have_read));
In remote. setTextColor (summaryId, R. color. news_have_read); in this Code, R. color. news_have_read the int value generated through eclipse is not a true color value and must be passed through mContext. getResources (). getColor obtains the true hexadecimal color value #255 #255 #255 #255.
The following table is displayed in Android:
TableLayout t; TableRow row; @ Overridepublic void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); t = (TableLayout) findViewById (R. id. t); int z [] = {4, 3, 5}; ArrayList <View> v = new ArrayList <View> (); for (int x = 0; x <3; x ++) {row = new TableRow (this); for (int I = 0; I <z [x]; I ++) {TextView t1 = new TextView (this), t1.setText ("32323232"), t1.setTextColor (Color. BLACK); row. addView (t1);} t. addView (row );}}
Android development, there is no Color xml file in the res/Values folder in the environment, so I created a new problem.
Resources. getColor () check if your reference path is correct?
Android.blog.51cto.com/268543/302529i would like to recommend a special blog to you to illustrate the resource folder.