I need help adding a view to an AlertDialog

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

Hi, this is something that has been puzzling me lately. I have done this many times before in Objective-C and it worked fine, but it cannot be done in Titanium currently and is a simple fix. However, I can implement it myself into the classes but I need someones help on how to do it. I would like to add a window (or any object really such as a textfield) into an AlertDialog. In Objective-C it is done exactly the same as adding a subview to a normal view, you would use the line:

[alertView addSubview:textField];

However, on Titanium this isn't implemented. This should be REALLY easy to do, as most elements support the .add() property, but I just need to get it working on the AlertDialog. Android is not an issue, since Titanium already supports it. Any help would be greatly appreciated, this is essential to me as I need a textfield inside an AlertDialog and recreating it manually will never have the native look and feel. Thanks, Joseph.

— asked 12 months ago by Joseph Rautenbach
1 Comment
  • There is pending pull request for latest branch at https://github.com/appcelerator/titanium_mobile/pull/2789

    You can fetch latest master branch, patch it with this pull request code and compile it.

    — commented 9 months ago by Hidayet Doğan

1 Answer

Hi Joseph,

I think you should try to build module of native program and then add module to your project this is the best way that you can extend your code. If you want to do this then it is great and thankful if you share.

Otherwise there is an another way that I do when I have to develop this type of functionality is, take container view, set its background|Color is black and add it to window. change its opacity to 0.3 or change it to as per desire.

Take another view and set its background image that look like a alert dialog box. add text box and button into that view,

Add this alert dialog box view into container view and add click event on container. Hide container view when alert dialog view's button clicked.

Your Answer

Think you can help? Login to answer this question!