I am trying to display a dialog in the onClick method of a TextView. I tested the onClick without the dialog box using a log and it works. When I add the dialogbox to it, like this:
Context context = getApplicationContext();
Dialog d = new Dialog(context);
d.setTitle("Test");
TextView testField = new TextView(context);
testField.setText("Success!");
d.setContentView(testField);
d.show();
This is all in a textView's onClick method. The exception I get says unable to add window -- token null is not for an application.
Can someone please explain to me why this isn't working. I have tons of questions here about getting exceptions in android and the answer always has to do with the order of the code. Is there a reference somewhere about how code should be ordered?!
Thanks!