I've completed most of the game I'm attempting to make and throughout the project I've created one particular Activity which also calls a SurfaceView and a Thread. I put an update() method in each of the 3 classes so they each know where the other ones are everytime something changes. Apparently, the only way to do something like this is using static methods... This is fine until a collision occurs in my SurfaceView and I want to tell the Activity what to do. I can relay the information, but then I cannot find a way to make an AlertDialog.
I understand I cannot call showDialog() from a Static method, but I cannot find a way to make a non-static method to call it with and then call that method from a static one. I've been searching for an answer and I've heard something about instantiating the object but I cannot figure out what that means...
If anyone has a good idea to get me around this, please let me know :)
Alert Dialog code has three methods:setTitle() method for displaying the Alert Dialog box Title. setMessage() method for displaying the message. setIcon() method is used to set the icon on the Alert dialog box.
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
AlertDialog. A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout.
Android AlertDialog is composed of three regions: title, content area and action buttons.
Here is what I used:
public static void messageDialog(Activity a, String title, String message){
AlertDialog.Builder dialog = new AlertDialog.Builder(a);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setNeutralButton("OK", null);
dialog.create().show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With