Hi Question about menu

by 鏅鸿秴 钖 » Fri, 23 Apr 2010 08:05:08 GMT


Sponsored Links
 i want to realize button pop-up optionmenu,

i write a button setOnClickListener, check this could pop-up menu ,

how to made it?

my code is:

case R.id.tools:
if(myMenu==null) {
                                        myMenu.add(0, 0, 0, 
"Add").setIcon(R.drawable.addfolderr);
                                        myMenu.add(0, 1, 0, 
"Delete").setIcon(R.drawable.delete);

                                }
                                onCreateOptionsMenu(myMenu);
                                break;
but method onCreateOptionsMenu(menu) not work;
type System.out.println("12334"); it could print ,but the menu not
work:(
anyone know how to make it work? or  had other way to pop-up menu

--



Hi Question about menu

by ~ TreKing » Fri, 23 Apr 2010 10:19:22 GMT


 




Try checking if (myMenu != null), since, you know, you probably want a valid
object to add stuff to.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
 http://sites.google.com/site/rezmobileapps/treking 

--


Sponsored Links


Other Threads

1. ProgressDialog and sub activities

Hi all,

I have a main activity that launches a sub activity when the user
clicks a button as follows:

private OnClickListener buttonDirectoryListener = new OnClickListener
() {
    public void onClick(View v) {
        Intent intent = new Intent();
        intent.setClass(Main.this, Sub.class);
        startActivity(intent);
    }
}

Unfortunatly, the onCreate method of the sub activity can take a long
time (server request, xml parsing, custom layout creation, ...). So I
want to display an indeterminate ProgressDialog while the sub activity
is being created and then dismiss it when main activity is no longer
visible. I found a few threads claiming that a separate thread
is needed to run the progress dialog. So I updated my code as follows:

ProgressDialog pd;

private OnClickListener buttonDirectoryListener = new OnClickListener
() {
    public void onClick(View v) {
        pd = new ProgressDialog(this);
        pd.setIndeterminate(true);
        pd.show();
        new Thread() {
            public void run() {
                Intent intent = new Intent();
                intent.setClass(Main.this, Sub.class);
                startActivity(intent);
            }
        }.start();
    }
}

@Override
public void onStop() {
    super.onStop();
    pd.dismiss();
}

It seems to work sometime. But most of the time, the ProgressDialog is
not showing (or disappareing fastly), I only get a black sreen until
the sub activity is shown. Poor effect. I guess it might lead to an
ANR dialog in real situation. I guess the main activity receives
onStop event before the sub activity is shown. I would like to
indicate loading through the ProgressDialog until the sub activity
gets ready to be displayed.

I'm convinced other developers are facing such a problem and I'm
probably doing something wrong. Any help is welcome. Thanks.
--~--~---------~--~----~------------~-------~--~----~

2. Input Method App

Hi, everyone,

Who can give me a link of an input method app which can replace QWERTY
keypad and fit a Non HVGA screen?

Thanks.



--~--~---------~--~----~------------~-------~--~----~

3. Improve scrolling speed

4. Sound interfering with Accelerometer and Orientation sensors?

5. Who know the detailed roadmap of android?

6. ListView and TextView in a LinearLayout - issue

7. Is JNI (Java Native Interface) sup ported in Android鈥檚 Java?