如下面代码所示,我有一些视图,我希望向视图中添加一个选择器颜色,这样当单击视图时,它的颜色就会发生变化。就像点击列表视图中的项目一样,这就是我想要做的。
我提到了一些帖子,并简要介绍了以下两项内容:
view.setBackgroundResource(android.R.attr.listChoiceBackgroundIndicator);//highlighted with red color
view.setBackground(android.R.attr.listChoiceBackgroundIndicator);//highlighted with red color
但是它不
默认情况下,我的XML中有一个颜色,我希望以编程的方式更改它。我不知道如何以编程方式访问highlight_color.xml中的highlight_color.xml项颜色.
主要java代码:
//BEGIN TEST COLOR
ColorStateList iconsColorStates = new ColorStateList(
new int[][]{
new int[]{-android.R.attr.state_checked},
我需要以编程方式更改actionbar标题的文本颜色。
根据SDK版本,我使用以下代码以稍微不同的方式设置颜色
int textColor = getResources().getColor(android.R.color.white);
if (Build.VERSION.SDK_INT >= 14) {
// Version 4+
int titleId = getResources().getIdentifier("action_bar_title", "id", "android");