Titanium OptionDialog with AndroidView

In this post we will see how to create a customize OptionDialog in Android, remember only in Android. Did you see Titanium Runtime error notification dialog box. It’s OptionDialog box? Yes it is. We can also create same Custom option Dialog box, we have a property for this in optionDialog, it is AndroidView .

OptionDialog with AndroidView in Titanium
OptionDialog with AndroidView in Titanium

Ok let see How to create, first check with  Appcelerator Titanium developer documentation  http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.UI.OptionDialog-property-androidView
We can pass Ti.UI.View to androidView. So here I am creating a login view like this

var loginView =Ti.UI.createView({
layout:'vertical',
backgroundColor:'#467cb3'
});

var txtUserName = Ti.UI.createTextField({
hintText:’User Name’,
top:2,
width:Ti.UI.FILL
});
loginView.add(txtUserName);

var txtPassword = Ti.UI.createTextField({
hintText:’Password’,
passwordMask:true,
top:2,
width:Ti.UI.FILL
});
loginView.add(txtPassword);

And now just assign the loginView to androidView of OptionDialog.

Like this
Ti.UI.createOptionDialog({
title:'Login',
buttonNames:['Login','Cancel'],
androidView:loginView;
});

You Can check with my full code here in Github.

3 thoughts on “Titanium OptionDialog with AndroidView

Leave a Reply