I have added LienarProgressIndicator
in xml i.e com.google.android.material.progressindicator.LinearProgressIndicator
which I need to set value as soon as there’s change in values, Other values update correctly but LPI doesn’t seem to update value. It works if I set a static value to it rather than calculated one.
private fun updateDashboard(binding: ActivityMainBinding) {
val totalAmount = transactions.sumOf { it.amount }
val budgetAmount = transactions.filter { it.amount > 0 }.sumOf { it.amount }
val expenseAmount = totalAmount - budgetAmount
val spentPercent = ((expenseAmount / budgetAmount) * 100)
binding.apply {
"₹ %.2f".format(totalAmount).also { balanceTV.text = it }
"₹ %.2f".format(budgetAmount).also { budgetTV.text = it }
"₹ %.2f".format(abs(expenseAmount)).also { expenseTV.text = it }
"%.0f%%".format(abs(spentPercent)).also { spentPercentTV.text = it }
"₹ %.0f".format(budgetAmount).also { budgetTV2.text = it }
}
progressIndicator.setProgress(spentPercent.toInt(), true)
}