Comments (5)
Hi,
could you post some example code that uses submenus? I'm unable to create them programmatically or through a xml menu resource.
edit: I forgot to mention I'm trying to create them on a phone. Is this possible?
Thanks!
Paul
from actionbarsherlock.
The 'styled' sample contains two submenus which are created from a menu XML. Here is a snippet of one of them:
<item android:id="@+id/menu_nav" android:title="@string/action_label_nav">
<menu>
<group android:id="@+id/menu_nav_group" android:checkableBehavior="single">
<item android:id="@+id/menu_nav_tabs" android:title="@string/action_label_nav_tabs" android:checked="true" />
<item android:id="@+id/menu_nav_drop_down" android:title="@string/action_label_nav_drop_down" />
<item android:id="@+id/menu_nav_label" android:title="@string/action_label_nav_label" />
</group>
</menu>
</item>
The <group>
tag is only utilized here because the sub-menu items are all checkable.
Creating the above menu prorgammatically would start something like this:
public void onCreateOptionsMenu(Menu menu) {
SubMenu subMenu = menu.addSubMenu(0, R.id.menu_nav, 0, R.string.action_label_nav);
subMenu.addItem(0, R.id.menu_nav_tabs, 0, R.string.action_label_nav_tabs);
subMenu.addItem(0, R.id.menu_nav_drop_down, 0, R.string.action_label_nav_drop_down);
subMenu.addItem(0, R.id.menu_nav_label, 0, R.string.action_label_nav_label);
}
In this example I use R
attributes for the ids and titles but you may use literal numbers and strings as well.
from actionbarsherlock.
Thank you!
On a tablet, this works great, but I'm unable to get it working on pre-3.0 devices, so I'm guessing it's just for tablets.
from actionbarsherlock.
Hola, como puedo hacer que al hacer touch en un item se despliegue una lista ??
from actionbarsherlock.
Como se puede hacer el siguiente menú por código sin usar un layout.xml.
Translate:
Can this be done straight through Java or must I use layout.xml?
<item
android:icon="@drawable/menu"
android:showAsAction="ifRoom">
<menu android:id="@+id/menuopciones">
<item
android:id="@+id/vivo"
android:title="VIVO"
android:showAsAction="ifRoom|withText"
android:icon="@drawable/vivoon"
/>
<item
android:title="VOD"
android:id="@+id/vod"
android:showAsAction="ifRoom|withText"
android:icon="@drawable/vodon"
/>
<item
android:title="RPVR"
android:id="@+id/npvr"
android:showAsAction="ifRoom|withText"
android:icon="@drawable/npvron"
/>
</menu>
from actionbarsherlock.
Related Issues (20)
- Android 5 crash HOT 1
- can not import with build-tools-21.0.2 HOT 1
- Android L Upgrade HOT 1
- ActionBar Height is double in landscape on GT-S5360 2.3.6
- No resource found that matches the given name 'Theme.AppCompat.Light' HOT 1
- Sherlock dialog not dislpaying on devices with android v4+? HOT 1
- different proform in different devices
- ActionBarSherlock is incompatible with Appcompat HOT 4
- Various png files generate libpng warnings in Android Studio 1.1.0 or Gradle HOT 2
- SherlockFragmentActivity with TabHost, the item activity getActionBar null HOT 1
- Compile with API level 22 error: Error:In <declare-styleable> SherlockSpinner, unable to find attribute android:popupPromptView
- Migrating from sherlock to appcompat does not reduce apk size HOT 1
- Alert Dialogue and Pop up menu theme
- "titleTextStyle" has already been defined
- Watson.java mFragmens.mAdded can't find HOT 8
- Watson.java HOT 1
- Test
- Sherlock? HOT 1
- Tab size issue with Android 7.0 HOT 2
- SherlockActionbar conflicts with latest FacebookSdk facebook-android-sdk:[4,5) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actionbarsherlock.