Skip to content

Instantly share code, notes, and snippets.

@AppWerft
Created December 31, 2016 16:20
Show Gist options
  • Save AppWerft/93055c892cee4ed62cac6bd7f57766ed to your computer and use it in GitHub Desktop.
Save AppWerft/93055c892cee4ed62cac6bd7f57766ed to your computer and use it in GitHub Desktop.
var activity = $.getActivity();
if (activity) {
activity.onCreateOptionsMenu = function(e) {
activity.actionBar.displayHomeAsUp = true;
e.menu.clear();
e.menu
.add(
{
title : 'Weg damit!',
showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS,
icon : "/assets/trash.png"
})
.addEventListener(
"click",
function() {
var dialog = Ti.UI
.createAlertDialog({
cancel : 1,
buttonNames : [ 'Ja',
'Nein' ],
message : 'Wollen Sie den Beleg tatsächlich löschen?',
title : 'Belegverwurf'
});
dialog
.addEventListener(
'click',
function(e) {
if (e.index === e.source.cancel) {
Ti.API
.info('The cancel button was clicked');
} else {
Adapter.deleteReceipt(id);
$.close();
}
});
dialog.show();
});
e.menu
.add(
{
title : 'Hoch damit!',
showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS,
icon : "/assets/upload.png"
})
.addEventListener(
"click",
function() {
alert("Der Endpunkt ist leider noch nicht eingerichtet.");
});
};
activity.invalidateOptionsMenu();
}
activity.actionBar.onHomeIconItemSelected = function() {
$.close();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment