Hello,

I tried it, but it didn't work. now it crashes if i select the option
("application XXX has stopped unexpectedly" message pops up).
Can you tell me where did I go wrong?
This is how I implement it (the code below).

Thanks


        public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo){
                super.onCreateContextMenu(menu, v, menuInfo);
                MenuItem addItem = menu.add("the custom menu");
                addItem.setOnMenuItemClickListener(custommenu);

        }

        private MenuItem.OnMenuItemClickListener custommenu = new
MenuItem.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
                Toast.makeText(AlarmMenu.this, "custom menu",
Toast.LENGTH_LONG).show();
                return true;
        }
    };



On Mar 16, 4:15 am, Makas Tzavellas <[email protected]> wrote:
> It is done when you create the menu item for the context menu.
>
> For example,
>
>         MenuItem addItem = menu.add("Add");
>         addItem.setOnMenuItemClickListener(menuItemClickListener);
>
> The "menu" variable refers to the ContextMenu parameter that you receive
> from onCreateContextMenu. Your class that is responsible to create the menus
> into the context menu should probably have MenuItemClickListener as an
> additional parameter as well.
>
> On Tue, Mar 16, 2010 at 11:43 AM, ccal <[email protected]> wrote:
> > Hey Makas,
> > Thanks for the reply.
>
> > I actually didn't use MenuItemClickListener at all.
> > I use registerForContextMenu, onCreateContextMenu, and
> > onContextItemSelected .
> > Where should I fit setOnMenuItemClickListener(listener) in between
> > these?
>
> > Thanks
>
> > On Mar 15, 5:32 pm, Makas Tzavellas <[email protected]> wrote:
> > > Are you sure that you have set the MenuItemClickListener
> > > "setOnMenuItemClickListener(listener)" on the MenuItems properly?
>
> > > Makas
>
> > > On Mar 14, 4:27 am, ccal <[email protected]> wrote:
>
> > > > Hello,
>
> > > > I am creating a context menu in separate class from the listview,
> > > > because the contextmenu will be access by several listviews in
> > > > different classes.
> > > > Whenever I long-click the listview, contextmenu pops up, but nothing
> > > > happens when the options were chosen.
> > > > Tried to look at logcat message and it said something like this:
>
> > > > Window already focused, ignoring focus gain of:
> > > > com.android.internal.view.iinputmethodclient$stub$pr...@43c488f8
>
> > > > Any idea what really causing this problem?
> > > > cause it works perfectly fine if i put the contextmenu on the same
> > > > class as listview.
>
> > > > Thanks
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

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

Reply via email to