Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10832] Android: Picker by default is not centered in 2.1.2 Build (regression issue)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2012-09-14T10:18:07.000+0000
Affected Version/sRelease 2.1.2
Fix Version/sn/a
ComponentsAndroid
Labelsapi, parity, regression
ReporterAmuktha Akkinepally
AssigneeHieu Pham
Created2012-09-10T17:52:58.000+0000
Updated2017-03-23T17:55:23.000+0000

Description

This is a regression issue. The picker by default is not center Aligned when used Ti SDK 2.1.2. It works fine on 2.1.1GA. There is no property for picker to set Alignment. This works fine on iOS for both 2.1.1 and 2.1.2.

Steps to Reproduce:

1. Load the below app.js. 2. Test it on Android 2.3.3 or any above versions of Android for Ti SDK 2.1.1GA 3. Change the Ti SDK version to 2.1.2 in tiapp.xml file. 4. Test the app again on Android 2.3.3 Expected Behavior: It should behave similarly for both versions of SDKs. Actual Behavior: It behaves differently in 2.1.2GA.
/*global Ti,Titanium,alert */
var w = Ti.UI.createWindow({
	backgroundColor:'white'
});
var status = Ti.UI.createLabel({
	top: 5, left: 5, right: 5, height: 40, textAlign:'center'
});
w.add(status);

function showStatus(s) {status.text = s;}

var names = ['Joanie', 'Mickey', 'Jean-Pierre', 'Gustav', 'Raul', 'Mimi', 'Emily', 'Sandra', 'Carrie', 'Chachi'];
var verbs = ['loves', 'likes', 'visits', 'loathes', 'waves to', 'babysits', 'accompanies', 'teaches', 'announces', 'supports', 'knows', 'high-fives'];

var rows1 = [];
for (var i = 0; i < names.length; i++) {
	rows1.push(Ti.UI.createPickerRow({title: names[i]}));
}

var rows2 = [];
for (i = 0; i < verbs.length; i++) {
	rows2.push(Ti.UI.createPickerRow({title: verbs[i]}));
}

var rows3 = [];
for (i = (names.length -1); i >=0; i--) {
	rows3.push(Ti.UI.createPickerRow({title: names[i]}));
}

var column1 = Ti.UI.createPickerColumn( {
	rows: rows1, font: {fontSize: "12"}
});
var column2 = Ti.UI.createPickerColumn( {
	rows: rows2, font: {fontSize: "12"}
});
var column3 = Ti.UI.createPickerColumn( {
	rows: rows3, font: {fontSize: "12"}
});

var picker = Ti.UI.createPicker({
	useSpinner: true, visibleItems: 7,
	type : Ti.UI.PICKER_TYPE_PLAIN,
	top: 150, height: 200,
	columns: [ column1, column2, column3 ],
	align: 'center'
});

picker.addEventListener('change', function(e) {
	showStatus(e.selectedValue[0] + " " + e.selectedValue[1] + " " + e.selectedValue[2]);
});

w.add(picker);
var btnSelect = Ti.UI.createButton({
	left: 5, height: 40, top: 50, width: 150,
	title: 'Select idxs 2/4/6'
});
btnSelect.addEventListener('click', function() {
	picker.setSelectedRow(0, 2);
	picker.setSelectedRow(1, 4);
	picker.setSelectedRow(2, 6);
});
w.add(btnSelect);

var btnAdd = Ti.UI.createButton({
	left: 165, height: 40, top: 50, width: 150,
	title: 'Add "Manny"'
});
btnAdd.addEventListener('click', function() {
	picker.columns[0].addRow(Ti.UI.createPickerRow({title: 'Manny'}));
	picker.columns[2].addRow(Ti.UI.createPickerRow({title: 'Manny'}));
	showStatus('"Manny" added to columns 0 & 2');
});
w.add(btnAdd);

var btnRemove = Ti.UI.createButton({
	left: 5, height: 40, top: 100, width: 150,
	title: 'Remove all idx 3'
});
btnRemove.addEventListener('click', function() {
	picker.columns[0].removeRow( picker.columns[0].rows[3] );
	picker.columns[1].removeRow( picker.columns[1].rows[3] );
	picker.columns[2].removeRow( picker.columns[2].rows[3] );
	showStatus("value at index 3 of each col. removed");
});
w.add(btnRemove);

var btnCheckSelection = Ti.UI.createButton({
	left: 165, height: 40, top: 100, width: 150,
	title: 'Check sel.'
});
btnCheckSelection.addEventListener('click', function() {
	showStatus(picker.getSelectedRow(0).title + ' ' + picker.getSelectedRow(1).title + ' ' + picker.getSelectedRow(2).title);
	var color = status.backgroundColor || w.backgroundColor || "black";
	status.backgroundColor = 'red';
	setTimeout(function(){status.backgroundColor=color;},1000);
});
w.add(btnCheckSelection);
w.open();

Attachments

FileDateSize
picker in 2.1.1.jpg2012-09-11T14:53:57.000+00001141379
picker in 2.1.2.jpg2012-09-11T14:53:57.000+0000936230

Comments

  1. Ping Wang 2012-09-11

    Tested the sample app and KS->Control->Picker with 2.1.1.GA and 2.1.2.GA and master. Can not see any difference. Can you provide a screenshot to show where the issue is? (I can not open the images attached on Help Desk ticket).
  2. Lee Morris 2017-03-23

    Closing ticket as duplicate with reference to the linked issues above.

JSON Source