7

I set a background for a textview and I want to remove it dynamically but it dosen't work, are there any suggestion?

if (mToday) {
        monthView[mRow][mColumn].setBackgroundResource(R.color.black);
    }
    else {
        monthView[mRow][mColumn].setBackgroundResource(0);
    }

I found a reasonable explanation here why it is happen, but again didn't solve the problem.

Community
  • 1
  • 1
Mahdak
  • 111
  • 1
  • 1
  • 5

3 Answers3

11

try this.

txtEmail.setBackgroundResource(android.R.color.transparent);
Alex Kuzmin
  • 725
  • 5
  • 17
KDeogharkar
  • 10,939
  • 7
  • 51
  • 95
5

try the following code just changed 0 to null in .setBackgroundDrawable thats all it will work check once :

 if (mToday)
 {
     monthView[mRow][mColumn].setBackgroundResource(R.color.black);
 }
else
 {
      monthView[mRow][mColumn].setBackgroundDrawable(null);
 }
androidgeek
  • 3,440
  • 1
  • 15
  • 27
3

I think this should work

monthView[mRow][mColumn].setBackgroundDrawable(null);

AnujMathur_07
  • 2,586
  • 2
  • 18
  • 25