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

Android: Picker change listener doesn't work the first time

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 7.1.0
    • Component/s: Android
    • Labels:
    • Environment:

      Titanium SDK 7.0.1.GA
      Tested on Google Nexus 5X, Android 7.1.0 (Emulator)

    • Sprint:
      2018 Sprint 04 SDK

      Description

      The first time a Picker changes, the change event is not fired. The subsequent times everything is fine.

      Test code:

      View:

      <Alloy>
      	<Window class="container" onOpen="open" id="requestWindow" title="title">
      		<ScrollView id="scrollView" showVerticalScrollIndicator="true" >
      			<View id="infoView" >
      				<View width="Ti.UI.FILL" height="40dp" >
      					<Label class="labels" id="typeLabel" text="L('type')" />
      					<Picker id="pickerType" platform="android" onChange="pickerChange" />
      					<View bottom="0" width="Titanium.UI.FILL" height="0.5" backgroundColor="#c8c7cc"></View>
      				</View>
      				<View width="Ti.UI.FILL" height="40dp" id="halfDayView" >
      					<Label class="labels" id="halfDayLabel" text="L('halfDay')" />
      					<Picker id="pickerHalfDay" platform="android" onChange="pickerChange" />
      					<View bottom="0" width="Titanium.UI.FILL" height="0.5" backgroundColor="#c8c7cc"></View>
      				</View>
      			</View>
      		</ScrollView>
      	</Window>
      </Alloy>
      

      Controller:

      function open(){
      	
      }
       
      var halfDay = [];
      halfDay[0]=Ti.UI.createPickerRow({title:L('halfDay')});
      halfDay[1]=Ti.UI.createPickerRow({title:L('fullDay')});
       
      var type = [];
      loadTypes();
       
      function loadTypes() {
      	var url = "https://www.google.es";
      	var xhr = Ti.Network.createHTTPClient({
      		onload : function(e) {
      			// var json = JSON.parse(decodeURIComponent(this.responseText));
      			
      			// var datas = json.datas;
      			
      			var datas = {
      		        "vac_tipos": [
      		            {
      		                "tipo": "F",
      		                "nombre": "Festivos"
      		            },
      		            {
      		                "tipo": "V",
      		                "nombre": "Vacaciones"
      		            },
      		            {
      		                "tipo": "U",
      		                "nombre": "Puente"
      		            },
      		            {
      		                "tipo": "FF",
      		                "nombre": "Festivo Especial"
      		            },
      		            {
      		                "tipo": "NI",
      		                "nombre": "DIAS Navidad"
      		            }
      		        ]
      			    
      			};
      			
      			for (var i = 0; i < datas.vac_tipos.length; i++) 
      			{
      				type[i] = Ti.UI.createPickerRow({title: datas.vac_tipos[i].nombre});
      			}
      			
      			if (OS_ANDROID) 
      			{
      				$.pickerType.add(type);
      				$.pickerType.selectionIndicator = true;
      				
      				$.pickerHalfDay.add(halfDay);
      				$.pickerHalfDay.selectionIndicator = true;
      			}
      			
      		},
      		onerror : function(e) {
      			Ti.API.debug(e.error);
      		},
      		timeout : 5000		
      	});
      	xhr.open("GET", url);
      	xhr.send();
      }
       
      function pickerChange(){
      	Ti.API.info('Change listener triggered');
      }
      

      Style:

      "Window[platform=android]" : {
      	windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_STATE_HIDDEN
      }
       
      ".container": { 
      	backgroundColor:"#DCDCDC",
      }
       
      "#scrollView": {
      	layout: 'vertical'
      }
      "#infoView" : {
      	layout: 'vertical',
      	height: Ti.UI.SIZE
      }
       
      ".labels" : {
      	left: "10dp"
      }
       
      "Picker[platform=android]" : {
      	width: "35%",
      	borderColor: 'black',
      	borderWidth: '1',
      	right: "10dp"
      }
      

        Attachments

          Activity

            People

            • Assignee:
              ybanev Yordan Banev
              Reporter:
              gfigueras Guillermo Figueras
              Reviewer:
              Joshua Quick
              Tester:
              Lokesh Choudhary
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Source Code