我编程方式创建一个列表(没有一个ListView,只是将其添加到父)这样的元素:的TextView setTextColor()不工作
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_weight="1">
<TextView android:id="@+id/filiale_name"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<TextView android:id="@+id/lagerstand_text"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textSize="10sp" android:textColor="@color/red"/>
</LinearLayout>
而且,我已经定义的值有一些颜色/ colors.xml 。如您所见,ID为“lagerstand_text”的TextView默认将其颜色设置为红色。这样可行。
当创建Java中的元素,我做
lagerstandText.setText("bla");
和某些元素还我
lagerstandText.setTextColor(R.color.red);
等多种颜色。虽然我不称为setTextColor()的元素是红色的,但所有其他元素都是灰色的,无论我选择哪种颜色(即使它再次是相同的红色)。
这是为什么?
如果我的回答是helpfukl你可以接受答案 – 2011-05-30 14:22:09