Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

Carlos Jul2024

@Carlos Jul2024
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • What is the correct syntax to call onCreateOptionsMenu() and onPrepareOptionsMenu() in Android Studio?
    C Carlos Jul2024

    To maintain consistency and ensure proper functionality, follow these guidelines when implementing onCreateOptionsMenu() and onPrepareOptionsMenu() in an AppCompatActivity:

    onCreateOptionsMenu()
    Use the first example where you return true after inflating the menu. This is the recommended approach because super.onCreateOptionsMenu(menu) in AppCompatActivity always returns true by default and doesn't perform any additional actions unless overridden.

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.game_menu, menu);
    return true;
    }
    onPrepareOptionsMenu()
    Use the second example where you call super.onPrepareOptionsMenu(menu) first and return true later. This ensures any default behavior is executed, and returning true indicates the menu was successfully updated.

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.findItem(R.id.action_save).setVisible(true);
    menu.findItem(R.id.action_reset).setVisible(true);
    menu.findItem(R.id.action_about).setVisible(true);
    return true;
    }

    Android question android game-dev tutorial announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups