mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import observable = require("data/observable");
|
|
import action = require("ui/action-bar");
|
|
|
|
import pages = require("ui/page");
|
|
|
|
var currentPage:pages.Page;
|
|
// Event handler for Page "loaded" event attached in main-page.xml
|
|
export function pageLoaded(args: observable.EventData) {
|
|
// Get the event sender
|
|
var page = <pages.Page>args.object;
|
|
currentPage = page;
|
|
var textItem = new action.ActionItem();
|
|
textItem.text = "from loaded";
|
|
textItem.on("tap", () => {
|
|
console.log("item added in page.loaded tapped!!!");
|
|
});
|
|
page.actionBar.actionItems.addItem(textItem);
|
|
}
|
|
|
|
export function optionTap(args) {
|
|
console.log("item added form XML tapped!!!");
|
|
}
|
|
var i = 0;
|
|
export function buttonTap(args: observable.EventData) {
|
|
currentPage.actionBar.title = "hi " + i++;
|
|
|
|
if (currentPage.actionBar.android) {
|
|
if (i % 3 === 0) {
|
|
currentPage.actionBar.android.icon = "res://ic_test";
|
|
}
|
|
else if (i % 3 === 1) {
|
|
currentPage.actionBar.android.icon = "~/test-icon.png";
|
|
}
|
|
else if (i % 3 === 2) {
|
|
currentPage.actionBar.android.icon = undefined;
|
|
}
|
|
}
|
|
}
|
|
|