0

I want to add a ListView to the options menu so when clicked it will pop up and allow the user to scroll through it and interact it without the same as any other listview.

using something this for the XML:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
        <ListView android:id="@+id/menuGroupsList" android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
</menu>

and this for the code:

public boolean onCreateOptionsMenu(Menu menu) {
     MenuInflater inflater = getMenuInflater();
     inflater.inflate(R.layout.menu, menu);
     ListView list = (ListView)findViewById(R.id.menuGroupsList);
}

returns null from the findViewById.

Is this at all possible?

Thanks

Gal
  • 5,338
  • 5
  • 33
  • 55
  • I'm pretty confident that this is not possible. – goto10 Oct 24 '11 at 09:25
  • is options menu really what you need? or are you referring to context menu? I'm having a hard time visualizing how would an options menu look like with a listview in it. – Maggie Oct 24 '11 at 09:32
  • @Maggie well what I'm trying to achieve is a popup listview, but one that popups when clicking the settings button on the android. – Gal Oct 24 '11 at 09:34

1 Answers1

2

Don't use MenuInflater. Instead, create a custom layout with a list in it.
Override onPrepareOptionsMenu(..) and create a Dialog which you inflate with your custom layout.

Dialog dlg = new Dialog(context);
dlg.setContentView(R.layout.splashscreen);
dlg.show();
Maggie
  • 7,823
  • 7
  • 45
  • 66