Change background based on text in TextView in Android
<p>I'm trying to get the backgound of the layout to change based on what's in a textview. I know how to set the background in Java:</p>

<pre><code>mainbg.setBackgroundResource(R.drawable.erburrows);
</code></pre>

<p>but if I wrap that call in an if statement, nothing happens. There are no error flags or anything, it just doesn't display anything in the background. Here's the code I'm using:</p>

<pre><code>        //--- BACKGROUND CHANGE ---
    String tvString = showBook.getText().toString();
    bookDisp.setText(tvString);
    View mainbg = bgview.getRootView();
    if(bookDisp.equals("Green Eggs")){
    mainbg.setBackgroundResource(R.drawable.seuss);
    }else if (bookDisp.equals("Tarzan")){
        mainbg.setBackgroundResource(R.drawable.erburrows);
    }

    //--- END BACKGROUND CHANGE ---
</code></pre>

<p>Any idea why it doesn't work?</p>
