I am developing an android app, and in one fragment, I already have a listview and have a set of items that will be added to this listview via an arrayadapter. However, I was requested to dynamically color some list items based on a particular property in the original database, specifically bold only those elements to highlight them. Is there any possible way to acheve this with the arrayAdapter class, or if not, considering this is a simplistic use case, what can I do to achieve this
It's very easy to handle this problem you just have to put a condition in your adapter and if that condition is true you just have to customize your item as it's asked from you .
if(condition)
{
view.setBackgroundColor(activity.getResources().getColor(R.color.White));
}
And if you want to set a TextView as Bold programmatically in your adapter check your condition and set it like below :
textView.setTypeface(null, Typeface.BOLD);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With