Android: Table With Fields And Pickers Scrolls To Top On Field Data Entry

You must Login before you can answer or comment on any questions.

(Mobile App, Ti SDK 1.8.2, Android 4.0.3, Android Emulator, OS X 10.7, Titanium Studio, build: 2.0.2.201204191742)

To reproduce the problem in Android:

  1. Scroll down to a row that is off-screen when the App loads.
  2. Click into a field.
  3. Attempt to enter some text via the emulator's keyboard.

Expected result: The text is entered and the user can continue entering text.

Actual result: Only one character is entered into the field, the field loses focus, and the tableView scrolls to its top.

Without the pickers, field entry works as expected.

Demo Code:

var win =Ti.UI.createWindow({backgroundColor:'#fff'});
 
var captions = [];
var fields = [];
var rows = [];
var pickerRows = [];
 
for (var i = 0, ii=20; i<ii; i++){
    if(i%2==0){
        fields[i] = Ti.UI.createTextField({
            value:'field ' + i + ' contents',
            width:200,
            height:60,
            rowIndex:i
        });
    } else {
        fields[i] = Ti.UI.createPicker({
            type: Titanium.UI.PICKER_TYPE_PLAIN,
            selectionIndicator:true,
            width:200
        });
 
        if(i%5 == 0){
            fields[i].type = Titanium.UI.PICKER_TYPE_DATE;
        } else {
            for (var x = 0, xx = i; x<xx; x++){
                pickerRows[x] = Ti.UI.createPickerRow({
                    title:'row ' + x,
                    value:x
                });
            }
            fields[i].add(pickerRows);      
        }
    }
 
    captions[i] = Ti.UI.createLabel({
        text:'This is caption ' + i,
        width:200,
        height:60
    });
 
    rows[i] = Ti.UI.createTableViewRow({layout:'vertical'});
 
    rows[i].add(captions[i]);
    rows[i].add(fields[i]);
}
 
//  win.add(scrollView);
 
var tableView = Ti.UI.createTableView(
    {
        data:rows
    }
);
 
win.add(tableView);
 
win.open();
Does anyone have a work-around (other than ditching the table altogether)? Also, I don't have a device to test on at the moment, I'd appreciate it if someone can test this on a device and let me know if this is just an emulator issue.

Cheers!

2 Answers

Thanks for the reply, Ivan.

However, the "Android: tableView textField focus is lost while typing" issue appears to be fixed in my setup. As I mentioned in the initial post, field entry works as expected when no pickers are present on the table.

Your Answer

Think you can help? Login to answer this question!