User Tools

Site Tools


script_action_bar_sample

====== About the script ====== * Purpose : A sample script to configure and display the action bar, then react to button presses * Author : Pierre Hébert Starting at V14a9, Lightning allows the standard android action bar to be displayed in the home screen or in the app drawer (in which case it replaces the custom one). This API is available for Android devices >= 5.0. API reference: http://www.lightninglauncher.com/scripting/reference/api-alpha/reference/net/pierrox/lightning_launcher/script/api/screen/ActivityScreen.html#showActionBar(Function, Function) ====== How to use the script ====== Copy/paste the code below in a new script, then execute the script from a shortcut on your desktop. ====== Script code ====== <sxh javascript> bindClass("android.view.MenuItem"); getEvent().getScreen().showActionBar(create, select); function create(menu) { var item; item = menu.add("Hello action bar!"); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); item.setIcon(Image.createTextIcon("q", 96, 0xffffffff, 0, null).toDrawable()); item = menu.add("Another sample button"); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); item.setIcon(Image.createTextIcon("v", 96, 0xffffffff, 0, null).toDrawable()); item = menu.add("Settings"); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); return true; } function select(item) { alert(item.getTitle()); return true; } </sxh>

script_action_bar_sample.txt · Last modified: 2016/10/05 15:46 by pierrox