问题
I'm trying to implement optionsMenu in a WL application, testing it in Android (sdk level 10 in my project settings, runtime is Android 4.0.3). But no menu is available. I'm connecting to my local server through HTC usb pass-through, so i have to deal with worklight settings to change network address.
I've gone through IBM doc (WL getting started and infocenter), but there is no full explanation/code.
Here are my questions/issues:
1) how to deal with worklight settings in application-descriptor.xml (i need to access it as an additional optionsMenu item for local testing purpose):
<android version="1.0">
<worklightSettings include="true"/>
2) Where should i init the optionsMenu? (i call a function in the document.ready jquery function in my html page)
3) i've put icons (xxxx.png) in Android/native/res/drawable, is it enough?
4) are there specific issues with android sdk level 10 ?
回答1:
Since API Level 10, Google has started to introduce new UI controls. One of them is the Action Bar, which is the successor of the Options Menu. Worklight does not have full support for the Action Bar.
As a workaround, in AndroidManifest.xml
change the minSdkValue
to 8
, and this will bring back the 'regular' OptionsMenu
. It is in our wishlist for a future release to better handle this situation.
- You've declared it correctly.
- You can initialize it in
wlCommonInit()
(located atyourProject\apps\yourApp\common\js\appName.js
) - Yes. Be sure they are in the correct resolution per DPI(folder). However, I would put them in
nativeResources\res\<dpiFolder>
, because if you happen to delete your native folder, these images are gone as well. By putting them innativeResources
, they will be copied to the native folder once it is created upon build. - Yes, see above.
来源:https://stackoverflow.com/questions/15704539/worklight-optionsmenu