Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2191] Android: Add View support to AlertDialog

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:58:22.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0 M01
ComponentsAndroid
Labelsandroid, feature
ReporterDon Thorp
AssigneeDon Thorp
Created2011-04-15T03:13:09.000+0000
Updated2011-04-17T01:58:22.000+0000

Description

Add support for property 'androidView' as a platform specific option for AlertDialog. Note in the example I added a second invisible view to force the size of the message container. It's a side-effect of view as a top-most container.

var win = Ti.UI.createWindow({ backgroundColor : 'white'});
var btn = Ti.UI.createButton({
    title : 'Open Dialog'
});

btn.addEventListener('click', function(e) {
    var dialog = null;
    var view = Ti.UI.createView({
        backgroundColor : 'red',
        width : 200,
        height : 200
    });
    
    var v2 = Ti.UI.createView({
        wrap : false,
        width : 300,
        height : 300
    });
    view.add(v2);
    
    var viewBtn = Ti.UI.createButton({
        title : 'Click Me',
        width : 200,
        height : 200
    });
    view.add(viewBtn);
    
    viewBtn.addEventListener('click', function(e) {
        dialog.hide();
    });

    dialog = Titanium.UI.createAlertDialog({
        buttonNames : ['Cancel'],
        title:'I am a title',
            androidView : view
    }); 

    dialog.addEventListener('click', function(e) {
        Ti.API.error("CLICK - ID: " + e.index + " cancel: " + e.cancel + " button: " + e.button);
    });
    
    dialog.show();
});
win.add(btn);
win.open({animated:false});

Comments

  1. Don Thorp 2011-04-15

    (from [2f60d8ee7e2eda8de6380b8b654ff4cb6124e861]) [#2191] added support for view in AlertDialog. Since this is the base widget it's actually supported in any dialog on Android. Needs to be ported to master http://github.com/appcelerator/titanium_mobile/commit/2f60d8ee7e2eda8de6380b8b654ff4cb6124e861"> http://github.com/appcelerator/titanium_mobile/commit/2f60d8ee7e2ed...

  2. Don Thorp 2011-04-15

    (from [274ded5d85a8d4b5e918c175a83c615cf64aa256]) [#2191 state:fixed-in-qa] Support a Titanium view in a dialog. There is a layout issue where you have one extra view layer to get it to size correctly. This needs to be addressed when layout is reworked. https://github.com/appcelerator/titanium_mobile/commit/274ded5d85a8d4b5e918c175a83c615cf64aa256"> https://github.com/appcelerator/titanium_mobile/commit/274ded5d85a8...

  3. Matt Schmulen 2011-04-15

    pass android sim 1.6/2.1 Titanium SDK version: 1.5.0 (11/27/10 10:50 aeb004c)

JSON Source