Android 如何更改字符串数组或字符串数组元素的颜色
这将直接改变字符串值的颜色。我发现了很多,但所有答案都是针对字符串数组资源的。试试这个 您的字符串项如下所示Android 如何更改字符串数组或字符串数组元素的颜色,android,arrays,string,Android,Arrays,String,这将直接改变字符串值的颜色。我发现了很多,但所有答案都是针对字符串数组资源的。试试这个 您的字符串项如下所示 I want to change the color of each array element or whole array given bellow.so how can i achieve this? String[] title = { "Abundance",
I want to change the color of each array element or whole array given bellow.so how
can i achieve this?
String[] title = {
"Abundance",
"Anxiety",
"Bruxism",
"Discipline",
"Drug Addiction"
}
is there any way that
title.setColor or
title[0].setColor
<string-array name="menu_items" >
<item >Abundance</item>
<item >Anxiety</item>
<item >Bruxism</item>
<item >Discipline</item>
<item >Drug Addiction</item>
</string-array>
<string-array name="menu_items_labels" >
<item ><FONT COLOR="#006600"><b>Abundance</b></FONT></item>
<item ><FONT COLOR="#006600"><b>Anxiety</b></FONT></item>
<item ><FONT COLOR="#006600"><b>Bruxism</b></FONT></item>
<item ><FONT COLOR="#006600"><b>Discipline</b></FONT></item>
<item ><FONT COLOR="#006600"><b>Drug Addiction</b></FONT></item>
</string-array>
// For setting the html code "menu_items_labels" with font color white
Spinner spinner = (Spinner) findViewById(R.id.my_spinner);
spinner.setAdapter(new ArrayAdapter<CharSequence>(this,
R.layout.multiline_spinner_dropdown_item, myActivity.this.getResources().getTextArray(R.array.menu_items_labels)));
strTemp = getResources().getStringArray(R.array.menu_items)[spinner.getSelectedItemPosition()];