views:

193

answers:

1

Hi! I have a card game I created in android and it is possible to show the scores at any given time by clicking a menu option. I would like that scores dialog to show a different background image when it's loaded depending on factors like who's leading, etc. In my constructor, I have the following relevant code:

public ScoresDialog(Context context) {
    super(context);

    this.setTitle(R.string.scoresDialogHeading);
    setContentView(R.layout.scores_view);
...
}

I have tried getting that view to change it in the showDialog method i wrote like so:

        findViewById(R.layout.scores_view).setBackgroundColor(Color.BLUE);

However, I got a NPE... I tried moving this statement to the onStart method, thinking that the view is not yet initialized but got the same error... Any thoughts on what the right way to do something like that is? Thanks, E.

A: 

R.layout.scores_view is the id of the layout and not of the root view in the layout. You must have something like a LinearLayout in your scores_view.xml. Try to use the id of that one. I think it should be starting with R.id.------

yaourt
Yes, that did it, I tried it before but I had to do it from withing the dialog's show method, and it unfortunately doesn't replace the background on the entire dialog, but rather on the inner layout only.Thanks!