Context Menu

by MarQuel Middleton » Sun, 13 Sep 2009 06:20:09 GMT

Sponsored Links
 Im trying to set my application menus up and i cant seem to do it  can
someone help me out i would really appreciate it im real confused!! I
just want to be able to press my exit button and it close the app or
something of that nature.


import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

public class LimeDroid extends Activity {
    /** Called when the activity is first created.

     * @return */

        public boolean onCreateOptionsMenu(Menu menu){

                MenuInflater inflater = getMenuInflater();

                inflater.inflate(, menu);

                return true;


         public boolean onOptionsItemSelected(MenuItem item) {

    public void onCreate(Bundle savedInstanceState) {

        Intent intent = new Intent("Reverse");
        String variableToPass = null;
                intent.putExtra("INFO_TO_PASS", variableToPass);




Context Menu

by Mark Murphy » Sun, 13 Sep 2009 06:35:40 GMT


Here is a link to the menu documentation: 

There are many samples available. 

This example shows menu inflation, where you define the menu via an XML
file. There are many other samples showing onOptionsItemSelected() in
your SDK (platforms/android-1.5/samples wherever your SDK was installed). 

This example is really of how to use the preference system, but the
sample code shows onOptionsItemSelected() as well.

Here are two more samples: 

Beyond that, you can search Google for onOptionsItemSelected(). Or, you
can pick up a good book or three: 

You do not need a menu for that. The user can click the BACK button to
exit your activity.

Mark Murphy (a Commons Guy)  | 

Android Training in Germany, 18-22 January 2010: 


Sponsored Links

Context Menu

by Neilz » Wed, 14 Oct 2009 18:45:03 GMT

 Hi. I have a context menu, which appears when you press and hold over
a list item for around two seconds.

Is there a way to adjust the sensitivity of this? I'd like it to
appear more quickly, if that's possible?


Context Menu

by Neilz » Fri, 23 Oct 2009 17:27:27 GMT

 The Context Menu in my app (a ListActivity) is getting very annoying.
On new phone you have to select and hold the list item for so long
before the menu pops up, that it's really not very user friendly.

I want my context menu to pop up immediately when the list item is
selected. I can't find a way of triggering this. There is a method
onListItemClick() which tells me when an item has been clicked, but I
still can't use that info to trigger the context menu in any way.

What are my options here? Surely there must be some way of achieving


Context Menu

by skink » Fri, 23 Oct 2009 17:48:14 GMT


if you want your context menu to popup on single item selection then
how would you scroll very long list?


Context Menu

by Neilz » Fri, 23 Oct 2009 18:05:57 GMT

 Hmmm, good point :-)

The list I'm playing with isn't very long yet, so I hadn't noticed it.

The point is, I just changed phone from HTC Magic to HTC Hero, and the
hold duration to activate the menu is painfully long. It's not user
friendly - in fact I don't think a random user using this app would
even know that holding an item was an option! I want to be able to set
the duration of the hold required.


Context Menu

by Neilz » Sat, 24 Oct 2009 16:37:23 GMT

 > if you want your context menu to popup on single item selection then
how would you scroll very long list?

Having thought about it, I Don't agree with this... It's perfectly
usual for android to behave in this way. Think about when you are
scrolling through the apps how easy it is to open one of them by
mistake. You just have to get used to the touch sensitivity of the
screen and get better at scrolling, or selecting.

So, back to my original problem. If you can't adjust the sensitivity
required (I don't believe you can't!) to activate a ContextMenu, what
other options are there to pop up a menu?

Other Threads

1. how to fastboot flash radio, .img file

Commandnya apa ya buat flash radio_xxxx.img (img file) via fastboot?
Or apakah ada file .zip nya buat ERE36? spy lebih gampang flash nya

TIA ya

"Indonesian Android Community [id-android]" 

2. how to test OpenCore OMA1

Hi Dear,

i am learning about OpenCore OMA1 plugin.
can anybody advise how can i test it for my video file to play?


3. ContentResolver NullPointerException

4. How to speed up the browser of the Android Emulator for 2.1

5. How to register my listener to a particular port

6. onActivityResult is not triggered

7. Testing desire2nexus