I'm very new to Android so I'm mainly working with information from the Android Developer's page. By the time I did not add the code to the warning dialogue section, everything was great. Those who give the code alone, they get an error when I try to run it on the last line, saying that I should start the dialogue, but I think that I am receiving the Nullpointer Exposure whatever That's the case ... this is my code:
Protected Dialogue Peritoneity (id) {dialog dialog = null; Work to define the switch (id) {case NAME_MISSING_ID: // Dialog Alert dialog. Manufacturer Manufacturer = New AlertDialog Builder (this); Builder.setMessage ("Proceed without a name?") .setCancelable (false) .setPositiveButton ("Yes", New DialogInterface.OnClickListener () {public void onClick (Main DialogInterface dialog, int id) {MainActivity.this.finish ( );}}) .setNegativeButton ("No", New DialogInterface.OnClickListener () {public void onClick (DialogInterface dialog, int id) {dialog.cancel ();}}); AlertDialog Warning = Builder.Create (); break; Case HARD_SELECTION_ID: // work to define dialog alert dialog. Builder Builder 2 = New AlertDialog Builder (this); Builder2.setMessage ("This is a human! Are you sure?") .Setable (wrong) .set-positive button ("Yes", New Dialog interface. OnClicklist () {Click on Public Zero (Dialogue Interface Dialog, ) {MainActivity.this.finish ();}}) .setNegativeButton ("No", New DialogInterface.OnClickListener () {Click Public Zero (DialogInterface dialogue, id) {dialog.cancel ();}}); Alertmloug Warning 2 = Builder 2.create (); break; Default: dialog = null; } Return dialog; } If I do not initialize "dialog" for "blank", then I can not run the program. I am not trying to do anything crazy yet, any help would be great because I have trouble trying to figure out what this code is trying to do.
Thanks guys!
You are returning all the nonsense - see dialog variables, it has never been assessed .
You might want to change these lines:
AlertDialog Warning = Builder.Create ();
AlertDialog Alert 2 = Builder 2.create ();
To do this:
dialog = builder.Create ();
dialog = builder 2.cent ();
And next time let us trace the full stack.
Comments
Post a Comment