Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6965871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:07:03+00:00 2026-05-27T16:07:03+00:00

I did this menu and when I click a menu item nothing happens, it

  • 0

I did this menu and when I click a menu item nothing happens, it doesnt’t even shows the default toast! Maan I dont know what is going on!

<?xml version="1.0" encoding="utf-8"?>  
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/menuLapiz" android:alphabeticShortcut="l"
        android:icon="@drawable/pencil" />

    <item android:id="@+id/menuCirculo" android:alphabeticShortcut="c"
        android:icon="@drawable/circulo" />

    <item android:id="@+id/menuTriangulo" android:alphabeticShortcut="t"
        android:icon="@drawable/triangulo" />
    <item android:id="@+id/menuCuadrado" android:alphabeticShortcut="s"
        android:icon="@drawable/cuadrado" /> </menu>

DrawActivity.java
… Here I got the menu onOptionsSelected which appereantly is not working

import android.app.Activity
import android.os.Bundle;   
import android.view.Menu;  
import android.view.MenuInflater;  
import android.view.MenuItem;
import android.view.Window;  
import android.view.WindowManager;   
import android.widget.Toast;  `

public class DrawActivity extends Activity {

    DrawView drawView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Set full screen view
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // No Title
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        drawView = new DrawView(this);
        setContentView(drawView);
        drawView.requestFocus();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu){

        super.onCreateOptionsMenu(menu);
        MenuInflater awesome = getMenuInflater();
        awesome.inflate(R.menu.main_menu, menu);
        return true;
    }

    @Override 
    public boolean onOptionsItemSelected(MenuItem item){
        switch(item.getItemId()){
        case R.id.menuLapiz:
            Toast.makeText(this, "This is a toast", Toast.LENGTH_LONG);
            return true;
        default:
            Toast.makeText(this, "This is a toast", Toast.LENGTH_LONG);
            return true;
        }
    }}

I have no idea why the onOptionsItemSelected(MenuItem item) method is not working I already tried without the S of Options because I read that suggestion in other post but it did not work.

I’m new to android programming so I really have no clue of what is going on .. any help will be appreciated, thanks a lot!! pd: let me know if you want to see the DrawView.java class

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:07:04+00:00Added an answer on May 27, 2026 at 4:07 pm

    Add a return true; to the end of each case

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.mAdd:
            startActivity(new Intent("com.example.ADD"));
            return true;
    
        case R.id.mAbout:
            startActivity(new Intent("com.example.ABOUT"));
            return true;
    
        }
        return false;
    }
    

    EDIT: toast code

    Toast t = Toast.makeText(getApplicationContext(),
                        "This is a toast",
                        Toast.LENGTH_SHORT);
                t.show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how they did that effect? Check this link. If you click
Ok I know this is simple, in fact damn simple, I did this in
Alrighty, I don't know how I did this, probably the AS3 gods became angry
I want to make a similar navigation menu like what m.facebook.com did. but this,
I did right-click > refactor > move from the project menu, Move everything from
I did this tests and the results seems the count function scale linearly. I
I did this in the past, and can't remember the correct command (I think
i did this in msvc 2005. typedef void (*cleanup_t)(); void func(cleanup_t clean) { cleanup_t();
i did this: this.combobox.ItemsSource = Common.Component.ModuleManager.Instance.Modules; to bind the combobox to a collection, which
I did this: [User.first, User.last].to_xml and got this: <users type=array> <user> <created-at type=datetime>2010-03-16T06:40:51Z</created-at> <id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.