can't figure out this null point exception error
<p>making a coin flip option within an app.  Here's the part that's killing me:</p>

<pre><code>public ImageView tails;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    .....

}
</code></pre>

<p>in the menu is where the issue happens:</p>

<pre><code>public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {


case R.id.coin_flip:

                final Context cointext = this;
                final Dialog flip = new Dialog(cointext);
                flip.setContentView(R.layout.coin);

                flip.setTitle("Coin Flip");
                flip.setCancelable(true);

                n = 99;
                n = (generator.nextInt(n)) + 1;
                tails.findViewById(R.id.tails).setVisibility(1);

                if (n % 2 == 0) {
                    tails.findViewById(R.id.tails).setVisibility(0);
                }else {
                    tails.findViewById(R.id.tails).setVisibility(1);
                }

                Button flipBtn = (Button)findViewById(R.id.flipBtn);
                flipBtn.setOnClickListener(new View.OnClickListener() {

                    public void onClick(View v) {

                        if (n % 2 == 0) {
                            tails.findViewById(R.id.tails).setVisibility(0);
                        }else {
                            tails.findViewById(R.id.tails).setVisibility(1);
                        }
                    }
                });

                flip.show();
}
}
</code></pre>

<p>I keep getting a NullPointerException on:</p>

<pre><code>tails.findViewById(R.id.tails).setVisibility(1);
</code></pre>

<p>any ideas how to fix this?  Thanks in advance</p>
