American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

12 PM – Android Game Dev – Gamas

June 10, 2023 @ 12:00 pm - 1:00 pm

Homework
  1. In the MainActivity.java, if the user forgot to put either player1 name or player2 name. Prevent user from starting the game. You need to display an Android alert.
  2. Example on how to user Android alert:
    1. // import the necessary libraries
      import android.app.AlertDialog;
      import android.content.DialogInterface;
      
      // in your activity or fragment
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      
      builder.setTitle("Sample Alert");
      builder.setMessage("This is a simple alert box");
      
      // Add the buttons
      builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
      // User clicked OK button
      }
      });
      builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
      // User cancelled the dialog
      }
      });
      
      // Create the AlertDialog
      AlertDialog dialog = builder.create();
      
      // show the dialog
      dialog.show();

Details

Date:
June 10, 2023
Time:
12:00 pm - 1:00 pm
Verified by MonsterInsights