Hi everyone
I've been looking into this for a couple of hours and changed the code quite a few times however the nullpointerexception error is still appearing
The problem is occuring when my "WorkOn" class calls another class called "Dialogs"
So this is my WorkOn Class
Code (Java):
Code (Java):
-
public class Dialogs extends AppCompatActivity {
-
//constructor
-
this.context = context;
-
}
-
AlertDialog.Builder alert = new AlertDialog.Builder(Dialogs.this);
-
alert.setTitle("Work On File Saved");
-
alert.setMessage("[Displaying for Test] Work On File Saved");
-
alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
-
public void onClick(DialogInterface dialog, int which) {
-
// continue with delete
-
}
-
});
-
alert.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
-
public void onClick(DialogInterface dialog, int which) {
-
// do nothing
-
}
-
});
-
alert.setIcon(android.R.drawable.ic_dialog_alert);
-
alert.show();
-
}
-
}
Code (Java):
-
AlertDialog.Builder alert = new AlertDialog.Builder(Dialogs.this);
NullPointerException AlertDialog.Builder
Aucun commentaire:
Enregistrer un commentaire