Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15546] Android: TextField set in a listView headerView property loses focus once clicked

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-10-29T20:57:20.000+0000
Affected Version/sRelease 3.2.0
Fix Version/s2013 Sprint 22, 2013 Sprint 22 API, Release 3.2.0
ComponentsAndroid
Labelsmodule_listview, qe-3.2.0, qe-testadded, triage
ReporterFederico Casali
AssigneeHieu Pham
Created2013-10-21T18:21:09.000+0000
Updated2014-04-22T07:56:39.000+0000

Description

Problem Description

If a textField is set in a listView headerView property, it loses focus when clicked

Steps to reproduce

Sample code:
var sections = [];
      
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'});
var fruitDataSet = [
    {properties: { title: 'Apple', searchableText:' Fruits Apple', itemId:'0 0'}},
    {properties: { title: 'Banana', searchableText:'Fruits Banana', itemId:'0 1'}}
];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);

var tf = Ti.UI.createTextField({
        color: '#336699',
        height: 100,
        top:10,
        bottom:10,
        left:10,
        right:10,
        font:{fontSize:20,fontWeight:'bold'},
        hintText: 'Search'
    });

// tf.addEventListener('change',function(e){
//         listView.searchText = e.value;
//  });


var listView = Ti.UI.createListView({
	top: 20,
	headerView: tf
});
listView.sections = sections;


var win = Ti.UI.createWindow({
	backgroundColor:'black'
});

win.add(listView);

win.open();
1. Run the sample code on device 2. Click on the textField Result: keyboard is shown but then focus is immediately lost, so is actually not possible to type in. Works as expected on iOS. Using 3.1.3.GA the textField is not displayed at all.

Comments

  1. Hieu Pham 2013-10-21

    In order to use any textfields inside listview, whether in headerView or row, you need to set 'windowSoftInputMode:Ti.UI.Android.SOFT_INPUT_ADJUST_PAN' to the window.
  2. Hieu Pham 2013-10-21

    Looks like there's no documentation regarding this. I'll update the doc.
  3. Hieu Pham 2013-10-22

    master PR: https://github.com/appcelerator/titanium_mobile/pull/4819
  4. Federico Casali 2013-10-22

  5. Samuel Dowse 2013-11-01

    Tested using the given code with Federico's advice and currently works on: Mac OSX 10.9 Mavericks Titanium Studio, build: 3.2.0.201310310121 Titanium SDK, build: 3.2.0.v20131031141643 CLI: 3.2.0 Alloy: 1.2.2 +Devices+ Android Emulators: 2.3.3, 4.0, 4.1.2 and 4.3 Android Device: Samsung Galaxy Nexus running 4.1.1 Keyboard appears on screen and text field remains focused. Closing.

JSON Source