I edit the dominoes app..so when i click the delete button, it will show dialog, i made a code like this on GUImanager.java, initbutton method :
deleteButton = (Button) overlayView.findViewById(R.id.delete_button); deleteButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog.Builder aboutDialog = new AlertDialog.Builder(applicationContext); aboutDialog.setMessage("test"); /*Retry*/ aboutDialog.setNegativeButton("test", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog aboutAlert = aboutDialog.create(); aboutAlert.setTitle("test"); aboutAlert.show(); } });
but when i click on the deletebutton, the dominoes app force close..anyone know why that happen??did i make a mistake??
You might try moving this code into the main activity... It looks like Android AlertDialogs are quite picky about where they are created/shown from. There are lots of posts online with people having similar issues, e.g. http://stackoverflow.com/questions/1561803/android-progressdialog-show-crashes-with-getapplicationcontext
- Kim