Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-11569

Android: Picker does not work if put inside an AlertDialog

    Details

      Description

      Problem description

      Adding a picker to an alert dialog does not work on Android.

      Steps to reproduce

      • Use this code to reproduce the bug:

      var win = Titanium.UI.createWindow({
          title : 'Bug Isolation',
          backgroundColor : 'white',
          barColor : '#0066CC',
          navBarHidden : false,
          tabBarHidden : true
      });
       
      var alertView = Ti.UI.createView({
          top : '0dp'
      });
       
      var monthPicker = Ti.UI.createPicker({
        top : '5dp',
        width : '150dp',
        left : '5dp'
      });
       
      var months = [];
      months[0]=Ti.UI.createPickerRow({title:'January'});
      months[1]=Ti.UI.createPickerRow({title:'February'});
      months[2]=Ti.UI.createPickerRow({title:'March'});
      months[3]=Ti.UI.createPickerRow({title:'April'});
      months[4]=Ti.UI.createPickerRow({title:'May'});
      months[5]=Ti.UI.createPickerRow({title:'June'});
      months[6]=Ti.UI.createPickerRow({title:'July'});
      months[7]=Ti.UI.createPickerRow({title:'August'});
      months[8]=Ti.UI.createPickerRow({title:'September'});
      months[9]=Ti.UI.createPickerRow({title:'October'});
      months[10]=Ti.UI.createPickerRow({title:'November'});
      months[11]=Ti.UI.createPickerRow({title:'December'});
       
      monthPicker.add(months);
      monthPicker.selectionIndicator = true;
       
      var yearPicker = Ti.UI.createPicker({
        top : '5dp',
        width : '100dp',
        right : '5dp'
      });
       
      var years = [];
      var yearRange = {min: new Date().getFullYear(), max: (new Date().getFullYear() + 10)}
      for (var i = yearRange.min; i <= yearRange.max; i++){
          var item = Ti.UI.createPickerRow({title: i.toString()});
          years.push(item);
      }
       
      yearPicker.add(years);
      yearPicker.selectionIndicator = true;
       
      alertView.add(monthPicker);
      alertView.add(yearPicker);
       
      var expDateAlert = Ti.UI.createAlertDialog({
          title : 'Exp. Date:',
          buttonNames : ['Set', 'Cancel'],
          cancel : 1,
          androidView : alertView
      });
       
      expDateAlert.addEventListener('click', function(e){
          if (e.index == 0){
              Ti.API.info('monthPicker: ' + JSON.stringify(monthPicker.getSelectedRow(0).title));
              Ti.API.info('yearPicker: ' + JSON.stringify(yearPicker.getSelectedRow(0).title));
          }
      });
       
      var button = Ti.UI.createButton({
          title : 'click me',
          bottom : '5dp',
          height : '50dp',
          width : '200dp'
      });
       
      button.addEventListener('click', function(e){
          expDateAlert.show();
      });
       
      win.add(button);
       
      win.open();
      

      • Run the app and click the button: a dialog appears
      • Try to use the picker views: they won't work

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hpham Hieu Pham
                Reporter:
                dcassenti Davide Cassenti
              • Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-14803
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration