Reputation: 4255
I am very new to android-apps and I couldn't find an answer to my problem.
I created an ActionBar-Button (the one with the 3 dots) for my settings.
What I want to create is such a little "drop down menu" when I click that Button. For Example: I go to "People"-App -> Click the 3 Dots in the upper right Corner -> a menue with the options "Delete Contacts", "Send Contacts" ... shows up.
I want to create that little menue
I think those are called ContextMenu but I dont'know how to create one. This is my OnOptionsItemSelected, do I have to create the Menu here? and how?
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
//Create ContextMenu??
return true;
}
return super.onOptionsItemSelected(item);
}
Upvotes: 0
Views: 100
Reputation: 26
"What you mean is the default overflow-menu.
The Items will be put into the "..."-Menu when you specify the mas app:showAsAction=never
or ifRoom
like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_sync"
android:icon="@drawable/ic_sync"
app:showAsAction="ifRoom"
android:title="@string/synchronize"/>
<item
android:id="@+id/action_settings"
app:showAsAction="never"
android:title="@string/settings"/>
</menu>
Upvotes: 1
Reputation: 1
The developer pages for Android describe OptionMenus http://developer.android.com/guide/topics/ui/menus.html#options-menu.
Upvotes: 0