You should look at the Context menu examples in this article:
http://developer.android.com/guide/topics/ui/menus.html

You are setting up an Options menu, not a context menu.

On Sep 23, 7:40 pm, rb <rbs...@gmail.com> wrote:
> Hi,
>
> I am attempting to create a simple context menu that will show another
> screen and have some functionality.  What is happening is that if I
> select menu, I get the items (context menu) then when I select one of
> them, it does nothing.  What am I missing here?   Once you click on
> the item, should it not execute the class that you have indicated?
>
> Here's my code:
>
> This is in the main application:
> package com.calculator;
>
> import android.app.Activity;
> import android.content.Intent;
> import android.graphics.Color;
> import android.os.Bundle;
> import android.view.View;
> import android.widget.Button;
> import android.widget.TextView;
>
> public class Calculator extends Activity {
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
> ... code of the project ....
>
>     // context menu
>     public boolean onCreateOptionsMenu(android.view.Menu menu) {
>         super.onCreateOptionsMenu(menu);
>         menu.add("Setup")
>                 .setIcon(android.R.drawable.ic_menu_preferences)
>                 .setIntent(new Intent(this, setup.class));
>         menu.add("About")
>                 .setIcon(android.R.drawable.ic_menu_info_details)
>                 .setIntent(new Intent(this, about.class));
>         return true;
>     }
>
> }
>
> --------------------------------------------------
>
> Here's the code for the "setup.java" class.  I have created a layout
> page called "setup.xml".
> All this should do is show me.
>
> package com.calculator;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.widget.Toast;
>
> public class setup extends Activity {
>
>         �...@override
>             public void onCreate(Bundle savedInstanceState) {
>                 super.onCreate(savedInstanceState);
>                         setContentView(R.layout.setup);
>          }
>
> }
>
> --------------------------------------------------
>
> I have placed the setContentView(R.layout.setup); in the main and used
> different coding for context menus and it did show me the other
> screen, but if I select menu, it gives me the same context menu.  I
> figure that the above code would direct me to the individual class
> where you can code it specifically and show what you want.   Any ideas
> on what I am missing here?   Please forgive me as I am new to this.
> Any complete code would be appreciated.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to