How do I set a drawable as the background for a list view in a class?
if (array1.size() < 8)
{
lv1.setBackgroundDrawable(R.drawable.bgimghs2b);
}
is improper.
That's because you're not giving it a Drawable
, but an ID of a drawable. Try:
lv1.setBackgroundDrawable(getResources().getDrawable(R.drawable.bgimghs2b))
If you're in an activity. If not, then you need to get a Context
and call getResources()
on that.
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