When window opens, it immediately focuses to the searchbar inside tableview showing keyboard by default. This behavior is experienced in some devices only. I experienced it in Samsung Galaxy SII. The keyboard doesn't show up by default in Motorola DROID (old). This happens only in some devices,it runs perfectly in the emulator
This is happening in Google Nexus Tablet 7 (with AndroidOS 4.1).
1. Run the below code.
2. You can see the keyboard appears by default immediately when the window opens.
var win = Ti.UI.createWindow({backgroundColor: '#000000'});
var search = Titanium.UI.createSearchBar({
barColor:'#000',
showCancel:true,
height:43,
top:0
});
// create table view data object
var data = [
{title:'Row 1', hasChild:true, color:'red', selectedColor:'#fff'},
{title:'Row 2', hasDetail:true, color:'green', selectedColor:'#fff'},
{title:'Row 3', hasCheck:true, color:'blue', selectedColor:'#fff'},
{title:'Row 4', color:'orange', selectedColor:'#fff'},
{title:'Row 5'},
{title:'Row 6'},
{title:'Row 7'},
{title:'Row 8'},
{title:'Row 9'},
{title:'Row 10'},
{title:'Row 11'},
];
// create table view
var tableview = Titanium.UI.createTableView({
data:data,
search:search
});
// add table view to the window
win.add(tableview);
win.addEventListener('focus', function(e) {
search.blur();
});
win.open();
Are there any known workarounds? Tried to find a workaround for days.
Focus and keyboard behavior are very device specific in the Android ecosystem.Have you tried setting windowSoftInputMode to hidden on the window? http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-windowSoftInputMode http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Android-property-SOFT_INPUT_STATE_HIDDEN
Tested with 2.1.4.GA, latest 3.0CI and 3.1CI builds. The issue is reproducible. This is also seen in Nexus 7 tablet.
Adding windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_STATE_HIDDEN to the window seems to work for me.
Since the issue is device specific as mentioned in the comments, So, closing the issue.