deathsonic18
Newbie
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
This is my Dialogs class
The nullpointer excpection is happening because of
do you have any idea why this is happening?
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
Java:
public Context context = this;
Dialogs saveDialog = new Dialogs(context);
//constructor
public WorkOn(Context context) {
this.context = context;
}
public void OnTime(View v) {
saveDialog.WorkOnSavedDialog(v);
}
});
}
This is my Dialogs class
Java:
public class Dialogs extends AppCompatActivity {
public Context context = this;
//constructor
public Dialogs(Context context) {
this.context = context;
}
public void WorkOnSavedDialog(View v) {
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();
}
}
The nullpointer excpection is happening because of
Java:
AlertDialog.Builder alert = new AlertDialog.Builder(Dialogs.this);
do you have any idea why this is happening?