Toon Van Dooren
Toon Van Dooren

Reputation: 613

Android titanium finish() on button

Ok so i want to simulate the hardware previous button by doin this on a page.

var buttonBack = Ti.UI.createButton({
title:"Terug",
left:10,
right:10,
top:70,
height:50
});
Ti.UI.currentWindow.add(buttonBack);


buttonBack.addEventListener("click", function() {
     finish();
})

But i get an reference error telling me finish is not defined... Am i using this wrong? This is kinda my first titanium app so don't kill me plox :$

Upvotes: 0

Views: 829

Answers (1)

Eliasdx
Eliasdx

Reputation: 2180

finish is a method of Titanium.Android.Activity so you have to get the activity first:

var activity = Titanium.Android.currentActivity;
activity.finish();

Titanium.Android.Activity

Upvotes: 4

Related Questions