更改预定义布局的文本颜色
Change text color of a predefined layout
我到处搜索,但找不到这个简单问题的解决方案:我正在使用预定义的布局 R.layout.simple_list_item_1
但我找不到修改其中 TextView 的文本颜色的方法。
如果您不想使用自己的 XML 布局,您可以从该布局获取 TextView 并为其设置颜色。 R.layout.simple_list_item_1
中 TextView 的 ID 是 android.R.id.text1
(该布局参见 the source)。
TextView tv = (TextView) findViewById(android.R.id.text1);
tv.setTextColor(getColor(R.color.new_text_color);
我到处搜索,但找不到这个简单问题的解决方案:我正在使用预定义的布局 R.layout.simple_list_item_1
但我找不到修改其中 TextView 的文本颜色的方法。
如果您不想使用自己的 XML 布局,您可以从该布局获取 TextView 并为其设置颜色。 R.layout.simple_list_item_1
中 TextView 的 ID 是 android.R.id.text1
(该布局参见 the source)。
TextView tv = (TextView) findViewById(android.R.id.text1);
tv.setTextColor(getColor(R.color.new_text_color);