How to create popup window on android with titanium?

You must Login before you can answer or comment on any questions.

May I know how can I create a popup window in android with titanium? It is just like an alert box, without button and the layout can be customized. It will close when back button on phone is pressed. Thank you.

Ti:1.6, Android 2.2

— asked 5 years ago by David Lee

2 Answers

Hi David,

I believe you can achive what you want with this code:

var infoWin = Titanium.UI.createWindow({
    backgroundColor: '#FFFFFF',
    top: 0,
    left: 0,
    opacity: 1,
    zIndex: 100
You can add buttons, text and images to this window as you wish, even a button which calls infoWin.close() instead of using the back button on your device.

If you are looking for a normal alert, you can use this code:

var alertDialog = Titanium.UI.createAlertDialog({
    title: 'Are you sure?',
    message: 'Do you want to do this?',
    buttonNames: ['Yes','No'],
    cancel: 1
    if (e.index == 0) {
        //code to execute when the user clicked Yes.
        //code to execute when the user clicked No
This should pop a standard alert dialig in Android for you where you can check what the user did answer. The number of buttons are optional I think.

You can ofcourse omit the dialog listener, and use the alert for information only.

Hope this helps, Harald

— answered 5 years ago by Harald Sakshaug
answer permalink
  • Herald thanks for the input. May I know how to make border-radius for window?

    — commented 5 years ago by David Lee

  • I dont think border radius for Android works... Usually when I port my iPhone apps to Android, border, borderradius and such are the first which have to be removed...

    — commented 5 years ago by Harald Sakshaug

To create a true window that looked like a popup (e.g. didn't fully cover the other window) - I used the following code:

var w = Titanium.UI.createWindow({
borderSpace is set based on how much smaller the popup should be.

— answered 5 years ago by Frank A
answer permalink
  • Thanks for the answer Frank. May I know how to make border radius for window?

    — commented 5 years ago by David Lee

  • borderRadisu dont work for Android as far as I know...

    — commented 5 years ago by Harald Sakshaug

  • how to make this window close with the back button and go back to th previous window? I have tried but it failed. It closes the window that open the new window too. I have tried to add{modal:true}); but error alert box appeared and close the app to close. Thanks.

    — commented 5 years ago by David Lee

  • Show 1 more comment

Your Answer

Think you can help? Login to answer this question!