I need a custom dialog to appear on button press. Here is my code:
Button button3 = (Button) findViewById(R.id.Button03);
button3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Dialog custdialog = new Dialog(this);
custdialog.setContentView(R.layout.custom_drink);
custdialog.setTitle("Custom Drink");
custdialog.setCancelable(false);
/etc.
However, on this line: final Dialog custdialog = new Dialog(this);
I get an error saying "The constructor Dialog(new View.OnClickListener(){}) is undefined".
I've tried replacing "this" with other things, but with no luck. It's odd that I get an error on this line because I have the exact same thing (except different names and stuff) in my project, beneath a switch (like this:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.settings:
final Dialog settingsdialog = new Dialog(this);
settingsdialog.setContentView(R.layout.custom_dialog);
settingsdialog.setTitle("Settings");
settingsdialog.setCancelable(false);
and that one works fine... hmmm.