Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17792] Android: showTimePickerDialog does appear if you didn't added the picker before.

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2017-06-13T22:11:04.000+0000
Affected Version/sRelease 3.3.0, Release 3.4.0
Fix Version/sRelease 6.2.0
ComponentsAndroid
LabelsTCSupportTriage
ReporterJoseandro Luiz
AssigneeLokesh Choudhary
Created2014-09-24T08:31:44.000+0000
Updated2017-06-26T17:52:10.000+0000

Description

Problem Description

showTimePickerDialog doesn't work if you don't add the picker before to the window.

Steps to reproduce

1. Create a new mobile project 2. Add this testcase to app.js:
var win = Ti.UI.createWindow({
    exitOnClose: true
});
 
var picker = Ti.UI.createPicker({
    type: Ti.UI.PICKER_TYPE_TIME
});

var btn = Ti.UI.createButton({
    title : 'Show time picker dialog'
});

win.add( btn );
win.open( );

btn.addEventListener( 'singletap', function( ) {
    picker.showTimePickerDialog({
        callback: function( e ) {
            if ( e.cancel ) {
                Ti.API.info( 'User canceled dialog' );
            } else {
                Ti.API.info( 'User selected time: ' + e.value );
            }
        }
    });
});
Console output message:
[WARN]  HardwareRenderer: Attempting to initialize hardware acceleration outside of the main thread, aborting
3. Run it in device. 4. Click on show the picker.

Workaround

Set the left element to -1000 (or any negative number outside of the screen, and add the picker to the window.
var win = Ti.UI.createWindow({
    exitOnClose : true,
    layout : 'vertical'
});
  
var picker = Ti.UI.createPicker({
    type : Titanium.UI.PICKER_TYPE_TIME,
    top : 10,
    left:-1000,
});
  
win.add(picker);
 
var btn = Ti.UI.createButton({
    title : 'Show time picker dialog',
    top : 10
});
  
win.add(btn);
//win.add(picker);
win.open();
  
btn.addEventListener('singletap', function() {
    picker.showTimePickerDialog({
        callback : function(e) {
            if (e.cancel) {
                Ti.API.info('User canceled dialog');
            } else {
                Ti.API.info('User selected time: ' + e.value);
            }
        }
    });
  
});

Comments

  1. Mauro Parra-Miranda 2014-09-26

    Workaround

    Set the left element of your picker to -1000, and add it to the window. Check this code:
       var win = Ti.UI.createWindow({
           exitOnClose : true,
           layout : 'vertical'
       });
        
       var picker = Ti.UI.createPicker({
           type : Titanium.UI.PICKER_TYPE_TIME,
           top : 10,
           left:-1000,
       });
        
       win.add(picker);
       
       var btn = Ti.UI.createButton({
           title : 'Show time picker dialog',
           top : 10
       });
        
       win.add(btn);
       //win.add(picker);
       win.open();
        
       btn.addEventListener('singletap', function() {
           picker.showTimePickerDialog({
               callback : function(e) {
                   if (e.cancel) {
                       Ti.API.info('User canceled dialog');
                   } else {
                       Ti.API.info('User selected time: ' + e.value);
                   }
               }
           });
        
       });
       
       
  2. Yordan Banev 2017-04-12

    PR: https://github.com/appcelerator/titanium_mobile/pull/8957
  3. Samir Mohammed 2017-06-26

    Verified fix in SDK Version: 6.2.0.v20170626084207. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/8957

JSON Source