Some time ago i\'ve made a simple dialog. Everything looks fine, but i\'m meeting troubles after trying to close it. The error is
\"void is an invalid type for the variab
Since you are trying to use the android:onClick attribute with "buttonOK"
, you must declare public void buttonOK(View v) {}
as a regular method in your class. (Currently you are trying to nest it inside aboutApp()
, also understand that you cannot nest methods in Java.)
public class MyActivity extends Activity {
Dialog dialog;
public void onCreate(Bundle savedInstanceState) { ... }
public void aboutApp(View view) {
// custom dialog
dialog = new Dialog(context);
...
}
// Move your method here:
public void buttonOK(View v) {
dialog.dismiss();
}
}