Skip to content Skip to sidebar Skip to footer

Why Set Setbackgroundcolor Is Not Working In My Custom Listview

I have a custom listView. The main layout xml is something like this: Copy

R.color.rojo is a resource, it is not color..

Solution 2:

You could also use setBackgroundColor() but you'll need to understand that is expects an object not a resource id. So you'd have to convert the resource to a color object, like so:

setBackgroundColor(getResources().getColor(R.color.rojo));

Solution 3:

To set color by setBackgroundColor method do this:-

setBackgroundColor(Color.parseColor("#e7eecc"));

either by

setBackgroundResource(R.color.<Your-Color>)

Solution 4:

.setBackgroundColor(getResources().getColor(R.color.raj));

Solution 5:

@RemotableViewMethodpublicvoidsetBackgroundColor(@ColorIntint color) {
    if (mBackground instanceof ColorDrawable) {
    ((ColorDrawable) mBackground.mutate()).setColor(color);
    computeOpaqueFlags();
    mBackgroundResource = 0;
    }else {
    setBackground(newColorDrawable(color));
    }
}

Its declaration is like this.

Post a Comment for "Why Set Setbackgroundcolor Is Not Working In My Custom Listview"