这就是style.xml
的样子:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#1976D2</item>
<item name="colorAccent">#FF4081</item>
...........
</style>
我想从Appliation类或Activity类以编程方式(使用"colorPrimary"
)覆盖"colorAccent"
和java
。任何人都可以帮助我如何使它成为可能吗?
注意:我不想为不同的主题创建多个style.xml
文件。我只是想以编程方式覆盖基本颜色,例如我希望从"colorPrimary"
#FF0000
#2196F3
到$(document).ready(function() {
var arr = [];
var arr2 = [];
var oTable = document.getElementById('example');
//gets rows of table
var rowLength = oTable.rows.length;
//loops through rows
for (i = 0; i < rowLength; i++){
//gets cells of current row
var oCells = oTable.rows.item(i).cells;
//gets amount of cells of current row
var cellLength = 1;
//loops through each cell in current row
for(var j = 0; j < cellLength; j++){
// get your cell info here
var cellVal = oCells.item(1).innerText;
arr.push(cellVal);
}
}
for (a = 0; a < rowLength; a++){
//gets cells of current row
var oCells = oTable.rows.item(a).cells;
//gets amount of cells of current row
var cellLength = 1;
//loops through each cell in current row
for(var b = 0; b < cellLength; b++){
// get your cell info here
var cellVal = oCells.item(7).innerText;
console.log(oCells.item(7).innerText);
if (arr[b] == '') {
oCells.item(7).innerText = "Pay";
} else {
oCells.item(7).innerText = "Paid";
}
arr2.push(cellVal);
}
}
});
。